Module:List

local utilsArg = require("Module:UtilsArg") local utilsFunction = require("Module:UtilsFunction") 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

local validate = utilsArg.validator({	type = {		oneOf = { "", "*", "#", "inline" },	}, })

function p.main(args) local errCategories = validate(args)

local type = args.type local delim = args.delim local items = utilsTable.map(mw.text.trim)(args) local notEmpty = utilsFunction.negate(utilsString.isEmpty) items = utilsTable.filter(notEmpty)(items) 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

return p