Module:Asbox stubtree: Difference between revisions
From Zoophilia Wiki
Jump to navigationJump to search
meta>WOSlinker No edit summary |
meta>WOSlinker No edit summary |
||
Line 3: | Line 3: | ||
function i._subtree(pagename) | function i._subtree(pagename) | ||
local out = {"",pagename} | local out = {"",pagename} | ||
local temp1 | local temp1 | ||
local r = 0 | |||
local t = {} | local t = {} | ||
Line 11: | Line 12: | ||
if tonumber(mw.ustring.sub(token,1,1)) == nil then | if tonumber(mw.ustring.sub(token,1,1)) == nil then | ||
table.insert(t,token) | table.insert(t,token) | ||
r = 1 | |||
end | end | ||
end | end | ||
Line 16: | Line 18: | ||
while (#t > 1) do | while (#t > 1) do | ||
table.remove(t, 1) | if r == 1 then | ||
r = 0 | |||
else | |||
table.remove(t, 1) | |||
end | |||
temp1 = table.concat(t, "-") .. "-stub" | temp1 = table.concat(t, "-") .. "-stub" | ||
table.insert(out,temp1) | table.insert(out,temp1) |
Revision as of 21:36, 25 February 2013
Documentation for this module may be created at Module:Asbox stubtree/doc
local i = {}
function i._subtree(pagename)
local out = {"",pagename}
local temp1
local r = 0
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)
r = 1
end
end
table.remove(t, #t)
while (#t > 1) do
if r == 1 then
r = 0
else
table.remove(t, 1)
end
temp1 = table.concat(t, "-") .. "-stub"
table.insert(out,temp1)
end
return table.concat(out, "\n* ")
end
function i.subtree(frame)
return i._subtree(frame.args["PAGENAME"])
end
return i