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:21, 12 August 2025 by CriticalResist (talk | contribs) (v3)
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 numbered list
    if #items == 0 then
        return ''
    end
    
    local list = {}
    for _, item in ipairs(items) do
        table.insert(list, '# ' .. item)
    end
    
    return '<div class="book-toc">\n' .. table.concat(list, '\n') .. '\n</div>'
end

return p