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 = utilsTable.merge(frame:getParent.args, frame.args) return p.main(args) end

function p.main(args) local errCategories = utilsArg.validate(args, {			type = {			enum = { "", "*", "#", "inline" },		},	})

local type = args.type local delim = args.delim local items = utilsTable.map(args, utilsString.trim) items = utilsTable.filter(items, utilsString.notEmpty) if not type then return utilsMarkup.list(items) end if type == "*" then return utilsMarkup.bulletList(items) end if type == "#" then return utilsMarkup.numberList(items) end if type == "inline" and delim then return table.concat(items, mw.getCurrentFrame:preprocess(delim)) end return mw.text.listToText(items) .. (errCategories and utilsMarkup.categories(errCategories) or "") end

-- TODO: WIP 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", 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.", },		}	} }

return p