Module:Asbox stubtree

From Zoophilia Wiki
Revision as of 20:52, 24 February 2013 by meta>WOSlinker (Created page with 'local i = {} function i._subtree(pagename) local out = {"",pagename} local temp1; local t = {} -- split items on dash into table for token ...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Documentation for this module may be created at Module:Asbox stubtree/doc

local i = {}
 
function i._subtree(pagename)
    local out = {"",pagename}
    local temp1;
    local t = {}
    -- split items on dash into table
    for token in mw.ustring.gmatch(pagename, "[^-]+") do
        -- don't add numbered items to list
        if tonumber(mw.ustring.sub(token,1,1)) == nil then
            table.insert(t,token)
        end
    end
    table.remove(t, #t)
    table.remove(t, 1)

    while (#t > 0) do
        temp1 = table.concat(t, "-") .. "-stub"
        table.insert(out,temp1)
        table.remove(t, 1)
    end

    return table.concat(out, "\n* ")
end

function i.subtree(frame)
    return i._subtree(frame.args["PAGENAME"])
end

return i