local p = {}
function p.main(frame)
local args = frame:getParent().args
local items = {}
-- Collect all TOC items
local i = 1
while args['item' .. i] do
table.insert(items, args['item' .. i])
i = i + 1
end
-- Generate TOC as wikitext ordered list
local toc = "{| class=\"wikitable\"\n|+\n!Table of Contents\n|-\n|"
toc = toc .. "'''Table of Contents'''\n\n"
toc = toc .. "<ol>\n"
for _, item in ipairs(items) do
toc = toc .. "<li>" .. item .. "</li>\n"
end
toc = toc .. "</ol>\n"
return toc
end
return p