Module:Correct typos in one click navigation

MyWikiBiz, Author Your Legacy — Thursday October 06, 2022
Jump to navigationJump to search


About

This is the module of {{Correct typos in one click navigation}}, and should only be called from its template.

Template:Sandbox other


local p = {}

function p.nav(frame)
	local wt_subp = '{| class="wikitable plainrowheaders" style="text-align: center;"\n|-\n'..
					 '! scope="row" | Subpage:'
	local wt_typos = '! scope="row" | Typos:'
	local h2_regex = '[\r\n]==%s*%[%[[^\r\n]+%]%]%s*=='
	local i = 0
	while i < 20 do
		i = i + 1
		local ele
		local ele_grey = '<span style="color:#888">'..i..'</span>'
		local subpi = 'Wikipedia:Correct typos in one click/'..i
		local subpi_content = mw.title.new(subpi, 4):getContent() --project space
		local dummy, n = mw.ustring.gsub(subpi_content, h2_regex, '%0')
		if n > 0 then
			ele = '[['..subpi..'|'..i..']]'
		else
			ele = ele_grey
			n = ''
		end
		wt_subp = wt_subp..'\n| '..ele
		wt_typos = wt_typos..'\n| '..n
	end
	return wt_subp..'\n|-\n'..wt_typos..'\n|}'
end

return p