<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ANUMBEROFSECTIONS%2Fsandbox</id>
	<title>Module:NUMBEROFSECTIONS/sandbox - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ANUMBEROFSECTIONS%2Fsandbox"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:NUMBEROFSECTIONS/sandbox&amp;action=history"/>
	<updated>2026-05-28T10:38:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:NUMBEROFSECTIONS/sandbox&amp;diff=144051&amp;oldid=prev</id>
		<title>imported&gt;Johnuniq: Johnuniq moved page Module:NUMBEROF/sandbox to Module:NUMBEROFSECTIONS/sandbox without leaving a redirect: implement Template talk:NUMBEROF#Requested move 3 May 2020 a little early to allow final development of the separate NUMBEROF and NUMBEROFSECTIONS functions</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:NUMBEROFSECTIONS/sandbox&amp;diff=144051&amp;oldid=prev"/>
		<updated>2020-05-06T03:35:02Z</updated>

		<summary type="html">&lt;p&gt;Johnuniq moved page &lt;a href=&quot;/research/Module:NUMBEROF/sandbox&quot; title=&quot;Module:NUMBEROF/sandbox&quot;&gt;Module:NUMBEROF/sandbox&lt;/a&gt; to &lt;a href=&quot;/research/Module:NUMBEROFSECTIONS/sandbox&quot; title=&quot;Module:NUMBEROFSECTIONS/sandbox&quot;&gt;Module:NUMBEROFSECTIONS/sandbox&lt;/a&gt; without leaving a redirect: implement &lt;a href=&quot;/index.php?title=Template_talk:NUMBEROF&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Template talk:NUMBEROF (page does not exist)&quot;&gt;Template talk:NUMBEROF#Requested move 3 May 2020&lt;/a&gt; a little early to allow final development of the separate NUMBEROF and NUMBEROFSECTIONS functions&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;
-- 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.sections(frame)&lt;br /&gt;
	local total = 0&lt;br /&gt;
	local needles = {}&lt;br /&gt;
	local haystack = &amp;#039;&amp;#039;&lt;br /&gt;
	-- Separate page names from # delimited string into table&lt;br /&gt;
	local pages = mw.text.split(frame.args[1], &amp;#039;%s?#%s?&amp;#039;)&lt;br /&gt;
	-- Separate whitespace delimited section level numbers into table&lt;br /&gt;
	local levels = mw.text.split(frame.args[&amp;#039;level&amp;#039;], &amp;#039;%s*&amp;#039;)&lt;br /&gt;
	-- Iterate through levels&lt;br /&gt;
	for level in mw.text.gsplit(table.concat(levels), &amp;#039;&amp;#039;) do&lt;br /&gt;
		-- and add the level needle to needles&lt;br /&gt;
		needles[#needles + 1] = &amp;#039;\n&amp;#039;..string.rep(&amp;#039;=&amp;#039;, tonumber(level))..&amp;#039;[^=]&amp;#039;&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&amp;#039;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(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>imported&gt;Johnuniq</name></author>
	</entry>
</feed>