<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ANUMBEROFSECTIONS</id>
	<title>Module:NUMBEROFSECTIONS - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ANUMBEROFSECTIONS"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:NUMBEROFSECTIONS&amp;action=history"/>
	<updated>2026-06-15T00:50:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:NUMBEROFSECTIONS&amp;diff=478763&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:NUMBEROFSECTIONS&amp;diff=478763&amp;oldid=prev"/>
		<updated>2021-07-16T05:03:13Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Unescape functionality grabbed from https://stackoverflow.com/a/14899740/1832568&lt;br /&gt;
local function unescape(str)&lt;br /&gt;
	str = string.gsub(str, '&amp;amp;#(%d+);', string.char)&lt;br /&gt;
	str = string.gsub(str, '&amp;amp;#x(%d+);', function(n) return string.char(tonumber(n, 16)) end)&lt;br /&gt;
	return str&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Counting function accepting a string haystack and table of needles&lt;br /&gt;
local function count(haystack, needles)&lt;br /&gt;
	local number = 0&lt;br /&gt;
	-- While we have needles to look for&lt;br /&gt;
	for index, needle in ipairs(needles) do&lt;br /&gt;
		-- find them all in our haystack&lt;br /&gt;
		for m in string.gmatch(haystack, needle) do&lt;br /&gt;
			number = number + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return number&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Function takes any number of # delimited page names and section level numbers&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local total = 0&lt;br /&gt;
	local needles = {}&lt;br /&gt;
	local haystack = ''&lt;br /&gt;
	-- Separate page names from # delimited string into table&lt;br /&gt;
	local pages = mw.text.split(unescape(frame.args[1]), '%s?#%s?')&lt;br /&gt;
	-- Separate whitespace delimited section level numbers into table&lt;br /&gt;
	local levels = mw.text.split(frame.args['level'], '%s*')&lt;br /&gt;
	-- Iterate through levels&lt;br /&gt;
	for level in mw.text.gsplit(table.concat(levels), '') do&lt;br /&gt;
		-- and add the level needle to needles&lt;br /&gt;
		needles[#needles + 1] = '\n'..string.rep('=', tonumber(level))..'[^=]'&lt;br /&gt;
	end&lt;br /&gt;
	-- For each page name in pages&lt;br /&gt;
	for index, page in ipairs(pages) do&lt;br /&gt;
		-- create a haystack to search from the page content&lt;br /&gt;
		haystack = mw.title.new(page):getContent()&lt;br /&gt;
		-- If we've requested the content of a legitimate page&lt;br /&gt;
		if haystack then&lt;br /&gt;
			--[[ pass the raw markup and needles to count&lt;br /&gt;
				 and add the return to total ]]&lt;br /&gt;
			total = total + count('\n' .. haystack, needles)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	--[[ then return how many sections of the required level&lt;br /&gt;
		 are in all the pages passed ]]&lt;br /&gt;
	return total&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>