Content deleted Content added
Fred Gandt (talk | contribs) to be expanded - pushing to module space early due to strange sandbox results |
Fred Gandt (talk | contribs) a few simple comments and preparedness for expansion |
||
Line 1:
local p = {}
-- Counting function accepting a string haystack and table of needles
local function count(
local
local index = 1
local
-- While we have needles to look for
while
for m in string.gmatch(raw, "\n" .. lev .. "[^=]") do▼
-- find them all in our haystack
nos = nos + 1▼
end
index = index + 1
end
return
end
-- Function accepting a page name and section level numbers
function p.sections(frame)
local
local
local title = mw.title.new(frame.args[1])
-- For every section level number
for
if
levels[#levels + 1] = string.rep("=", tonumber(value))▼
-- add the needle to our table of needles
needles[#needles + 1] = "\n" ..
end
end
-- then return how many needles are in our haystack
return count(title:getContent(),
end
|