Module:List

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

local customExists,FORMATS = pcall(require, "Module:List/custom"); local MODES = { main = function(str) return str .. " ";   end, nolist = function(str) -- Used for when all formatting operations should be in /custom. return str; end, with_links = function(str) local link,excess = str:match("^%[%[([^%]]-)%]%](.*)"); return link and ("" .. link .. "" .. excess .. ' ') or ("" .. str .. "" .. ' '); end, with_bulleted_links = function(str) local link,excess = str:match("^%[%[([^%]]+)%]%](.*)"); return link and ("\n* " .. link .. "" .. excess) or ("\n* " .. str .. ""); end, with_bullets = function(str) return "\n* " .. str; end }

local function list(mode) return function(frame) local list    = frame.args[1]; local custom  = frame.args[2]; local args    = { frame.args[3], frame.args[4], frame.args[5] }; local frm_list = list:gsub("([^,]+),?%s*",           (customExists and 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"; }