Module:List

local utilsArg = require("Module:UtilsArg") local utilsMarkup = require("Module:UtilsMarkup") local utilsString = require("Module:UtilsString") local utilsTable = require("Module:UtilsTable")

local p = {}

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates.List) if err then utilsMarkup.categories(err.categories) end return p.printList(args.listItems, args.type, args.delim) end

function p.printList(items, type, delim) if items == nil or #items == 0 then return "" end if not type then return utilsMarkup.list(items) elseif type == "*" then return utilsMarkup.bulletList(items) elseif type == "#" then return utilsMarkup.numberList(items) elseif type == "inline" and delim then return table.concat(items, mw.getCurrentFrame:preprocess(delim)) else return mw.text.listToText(items) end end

p.Templates = { List = { purpose = "This outputs bits of text in lists of various formats. This should be used instead  tag to make lists, so that the output HTML is semantically meaningful to screen readers (i.e. easier for the visually impaired to navigate).", format = "inline", paramOrder = {"type", "delim", "..."}, params = { type = { type = "string", nilIfEmpty = true, enum = {"*", "#", "inline"}, canOmit = true, desc = "Determines the list format. One of:  (bulleted list), # (numbered list),   (sentence list). If not specified, the list items are simply printed one per line.", },			delim = { type = "string", canOmit = true, desc = "If  is , then   sets the separator between each list item. If not specified, the inline list is printed as a phrase.", },			["..."] = {				name = "listItems", placeholder = "listItem", type = "content", desc = "List items. Can be any wikitext.", trim = true, nilIfEmpty = true, },		},		examples = { {"Link", "Zelda", "Ganon"}, { type = "*", "Link", "Zelda", "Ganon"}, { type = "#", "Link", "Zelda", "Ganon"}, { 				desc = "Inline lists.", args = { type = "inline", "Link", "Zelda", "Ganon"}, },			{ type = "inline", "Link", "Zelda"}, { type = "inline", "Link"}, { type = "inline", delim = "·", "Link", "Zelda", "Ganon"}, {				desc = "This template ignores empty arguments.", args = { type = "inline", "", "Zelda", "Ganon"}, },			{ type = "inline" }, { type = "*" }, {				desc = "This template ignores surrounding whitespace on parameters. If you desire whitespace in, use Template:Space.", args = { type = "inline", delim = "; ", " Link ", " Zelda ", " Ganon "}, },			{ type = "inline", delim = ";", "Link", "Zelda", "Ganon"}, },	}, }

return p