Jump to content

Module:ListLinks

From Drifters Almanac
Revision as of 04:40, 23 April 2025 by Mildew (talk | contribs)

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

local p = {}

function p.fromDelimited(frame)
    local raw = frame:getParent().args[1] or ""
    mw.log("Raw input: " .. raw)  -- Logs to Special:Log/Scribunto

    local delimiter = frame:getParent().args.delimiter or ","
    local list = mw.text.split(raw, delimiter)
    local output = {}

    table.insert(output, '<ul style="margin-left: 1em;">')
    for _, item in ipairs(list) do
        item = mw.text.trim(item)
        if item ~= "" then
            table.insert(output, string.format("<li>Item: %s</li>", item))
        end
    end
    table.insert(output, '</ul>')

    return table.concat(output, "\n")
end

return p