Module:List

-- Creates a formatted list from comma separated items. -- Module author: "The JoTS" --

local FORMATS = require("Module:List/custom") local MODES = require("Module:List/modes")

local function list(mode) return function(frame) --     local f = {...} --     local frame = #f == 1 and f[1] or {args=f,preprocess=function(...)return...end} local list    = frame.args[1] local custom  = frame.args[2] local args    = { frame.args[3], frame.args[4], frame.args[5] } -- Convert commas w/in links (to be ignored by list formatter) list = list:gsub("%[%[(.-)%]%]", function(link)           return table.concat({"", link:gsub(',', '%%2C'), ""})        end) -- Format list to desired form local frm_list = list:gsub("([^,]+),?%s*",           custom and custom ~= ""            and function(str)                return MODES[mode]( FORMATS[custom](str, args) ); end            or MODES[mode])

return frame:preprocess(frm_list) end end

return { main               = list "main", nolist             = list "nolist", with_links         = list "with_links", with_bulleted_links = list "with_bulleted_links", with_bullets       = list "with_bullets" }