Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:BookTOC

From ProleWiki, the proletarian encyclopedia
Revision as of 13:11, 12 August 2025 by CriticalResist (talk | contribs) (v2)
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