Module:List

local p = {} local h = {}

local utilsArg = require("Module:UtilsArg") local utilsString = require("Module:UtilsString")

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates.List) local categories = err and err.categoryText or "" local listItems = h.parseListItems(args.entries) return h.printList(listItems) end

function h.parseListItems(items) if #items == 1 then -- assume list items are delimited by commas instead of pipes local input = items[1] input = string.gsub(input, ",%s*$", "") -- strip dangling comma if present items = utilsString.split(input, '%s*,%f[^,%d]%s*') -- %f[^,%d] is so we don't split numbers on their thousands separator (e.g., 1,500) end return items end

function h.printList(items) if items == nil or #items == 0 then return "" end local html = mw.html.create("ul"):addClass("plainlist") for i, item in ipairs(items) do		html:tag("li"):wikitext(item) end return tostring(html) end

p.Templates = { List = { desc = "Renders each list entry on a separate line without any list markers such as bullets or numbers", format = "inline", params = { ["..."] = {				name = "entries", placeholder = "entry", type = "content", desc = "List items. Can be any wikitext.", trim = true, nilIfEmpty = true, },		},	}, }

return p