<?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%3ATable_template_counter%2Fsandbox</id>
	<title>Module:Table template counter/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%3ATable_template_counter%2Fsandbox"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Table_template_counter/sandbox&amp;action=history"/>
	<updated>2026-06-08T01:46:18Z</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:Table_template_counter/sandbox&amp;diff=147144&amp;oldid=prev</id>
		<title>imported&gt;SMAK: ←Created page with &#039;-- This module counts table rows with specified template name in wikitext.  local p = {} local getArgs  function p.main(frame) 	if not getArgs then 		getArgs = require(&#039;Module:Arguments&#039;).getArgs 	end 	return p._main(getArgs(frame, {wrappers = &#039;Template:Table template counter&#039;})) end  function p._main(args) 	-- Get the title object. 	local titleObj 	do 		local success 		success, titleObj = pcall(mw.title.new, args.page) 		if not success or not titleObj then...&#039;</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Table_template_counter/sandbox&amp;diff=147144&amp;oldid=prev"/>
		<updated>2022-07-18T09:52:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/index.php?title=WP:AES&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:AES (page does not exist)&quot;&gt;←&lt;/a&gt;Created page with &amp;#039;-- This module counts table rows with specified template name in wikitext.  local p = {} local getArgs  function p.main(frame) 	if not getArgs then 		getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs 	end 	return p._main(getArgs(frame, {wrappers = &amp;#039;Template:Table template counter&amp;#039;})) end  function p._main(args) 	-- Get the title object. 	local titleObj 	do 		local success 		success, titleObj = pcall(mw.title.new, args.page) 		if not success or not titleObj then...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module counts table rows with specified template name in wikitext.&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
local getArgs&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	if not getArgs then&lt;br /&gt;
		getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
	end&lt;br /&gt;
	return p._main(getArgs(frame, {wrappers = &amp;#039;Template:Table template counter&amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	-- Get the title object.&lt;br /&gt;
	local titleObj&lt;br /&gt;
	do&lt;br /&gt;
		local success&lt;br /&gt;
		success, titleObj = pcall(mw.title.new, args.page)&lt;br /&gt;
		if not success or not titleObj then&lt;br /&gt;
			titleObj = mw.title.getCurrentTitle()&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Get the page content.&lt;br /&gt;
	local content = titleObj:getContent()&lt;br /&gt;
	if not content then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Find the wikitables on that page.&lt;br /&gt;
	local wikitables = {}&lt;br /&gt;
	do&lt;br /&gt;
		local iWikitable = 0&lt;br /&gt;
		local s1 = content:match(&amp;#039;^({|.-\n|})&amp;#039;)&lt;br /&gt;
		if s1 then&lt;br /&gt;
			iWikitable = iWikitable + 1&lt;br /&gt;
			wikitables[iWikitable] = s1&lt;br /&gt;
		end&lt;br /&gt;
		for s in content:gmatch(&amp;#039;\n({|.-\n|})&amp;#039;) do&lt;br /&gt;
			iWikitable = iWikitable + 1&lt;br /&gt;
			wikitables[iWikitable] = s&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Find the wikitable to work on.&lt;br /&gt;
	local wikitable&lt;br /&gt;
	if args.id then&lt;br /&gt;
		for i, s in ipairs(wikitables) do&lt;br /&gt;
			if s:match(&amp;#039;^{|[^\n]*id *= *&amp;quot; *(%w+) *&amp;quot;&amp;#039;) == args.id then&lt;br /&gt;
				wikitable = s&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		wikitable = wikitables[tonumber(args.tableno) or 1]&lt;br /&gt;
	end&lt;br /&gt;
	if not wikitable then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Count the number of rows with the entered template name.&lt;br /&gt;
&lt;br /&gt;
	local count = 0&lt;br /&gt;
	if args.templatename then&lt;br /&gt;
		do&lt;br /&gt;
				local temp&lt;br /&gt;
				temp, count = wikitable:gsub(&amp;#039;|%-[|\n%-:;=\&amp;quot;\&amp;#039;%[%w%s%(%)%]]*%{%{&amp;#039;..args.templatename..&amp;#039;|[\&amp;#039;%[%a%s%(%|%d%)%]]+%}%}&amp;#039;, &amp;#039;{{&amp;#039;..args.templatename..&amp;#039;}}&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if count &amp;lt; 0 then&lt;br /&gt;
		count = 0&lt;br /&gt;
	end&lt;br /&gt;
	return count&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;SMAK</name></author>
	</entry>
</feed>