Jump to content

Module:ExplodeAndList

Di Wikipedia, e ensiklopedia liber
Revishon 10:24, 28 yüni 2024 hasí pa Kallmemel (papia | kontrib'nan)

Documentation for this module may be created at Module:ExplodeAndList/doc

-- Module:ExplodeAndList
local p = {}

function p.explodeAndList(frame)
    local titulonan = frame.args[1] or ""
    local nombernan = frame.args[2] or ""

    -- Split the inputs by the <br /> tag
    local titulonan_list = mw.text.split(titulonan, '<br />')
    local nombernan_list = mw.text.split(nombernan, '<br />')

    -- Initialize the result table
    local result = {}
    -- Iterate over the lists and combine them
    for i = 1, math.min(#titulonan_list, #nombernan_list) do
        table.insert(result, titulonan_list[i] .. '&nbsp;' .. nombernan_list[i])
    end

    -- Concatenate the result into a single string separated by newlines
    return table.concat(result, '\n')
end

return p