Module:Make list
Jump to navigation
Jump to search
local p = {}
local text_util = require('Module:Text Utility')
function p.split(splitstr, separator)
local b = text_util.split(splitstr, separator)
return b
end
function p.parse(args, type)
frame = mw.getCurrentFrame()
if args.args ~= nil then
args = args.args
end
local type = type or 'ul'
local separator = '%s*' .. (args[2] or ',') .. '%s*'
local style = args[3] or ''
local class = args[4] or ''
if style ~= '' then
style = ' style="' .. style .. '"'
end
if class ~= '' then
class = ' class="' .. class .. '"'
end
local prefix = '<' .. type .. class .. style .. '>'
local postfix = '</' .. type .. '>'
local b = p.split(args[1], separator)
local returnstr = ''
local returnstrformat
returnstrformat = function(segment)
return '<li>' .. segment .. '</li>'
end
for i, piece in ipairs(b) do
returnstr = returnstr .. returnstrformat(piece)
end
return prefix .. returnstr .. postfix
end
function p.makelist(frame)
return p.parse(frame.args, 'ul')
end
function p.makelistordered(frame)
return p.parse(frame.args, 'ol')
end
return p