Content deleted Content added
Fred Gandt (talk | contribs) check for nil vals |
Fred Gandt (talk | contribs) improved code in general BUT changed delimitation method for page args |
||
Line 4:
local function count(haystack, needles)
local number = 0
-- While we have needles to look for
-- find them all in our haystack
for m in string.gmatch(haystack, needle) do
number = number + 1
end
end
return number
end
-- Function
function p.sections(frame)
local total = 0
local needles = {}
local haystack = ""
-- Separate page names from # delimited string into table
-- Separate whitespace delimited section level numbers into table
-- Iterate through levels
▲ -- add the needle to our table of needles
▲ string.rep("=", tonumber(level)) .. "[^=]"
end
-- For each page name in
for index, page
-- get the raw markup
haystack = mw.title.new(page)
Line 52 ⟶ 36:
total = total + count(haystack:getContent(), needles)
end
end
--[[ then return how many sections of the required level
|