Module:Formatlist

-- -- Module:Formatlist -- -- Module for manipulating lists -- -- author: .jun

local p = {}

-- -- Accepts a list of items and formats it into an unordered list -- Used in infobox lists -- -- -- -- * List item 1 -- * List item 2 (descriptive text) -- * List item 3

function p.bold(frame)

args = frame:getParent.args local str = ''

for i, v in ipairs(args) do

local pattern = '( +%([^%)]+%))$'       local a = '*' .. '\'\'\ .. mw.ustring.gsub(v, pattern, ) .. '\'\'\''

if mw.ustring.find(v, pattern) then a = a .. mw.ustring.sub(v, mw.ustring.find(v, pattern)) end

a = a .. '\n'

str = str .. a

end

return str

end

-- -- Accepts a list of item with an index and formats it into an ordered list beginning from that index -- -- -- -- 12. List item 1 -- 13. List item 2

function p.ol(frame)

frame = frame.args local index = frame['index'] or 1 local str = ''

local args = 0 for i, v in ipairs(frame) do       args = args + 1 end

for i = 1, args do       str = str .. '' .. frame[i] .. '' end

str = str .. '' return str

end

return p