<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.agency/index.php?action=history&amp;feed=atom&amp;title=Module%3ATeamBracket-Tennis</id>
		<title>Module:TeamBracket-Tennis - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.agency/index.php?action=history&amp;feed=atom&amp;title=Module%3ATeamBracket-Tennis"/>
		<link rel="alternate" type="text/html" href="https://wiki.agency/index.php?title=Module:TeamBracket-Tennis&amp;action=history"/>
		<updated>2026-07-15T10:18:53Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.1</generator>

	<entry>
		<id>https://wiki.agency/index.php?title=Module:TeamBracket-Tennis&amp;diff=610&amp;oldid=prev</id>
		<title>Admin: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.agency/index.php?title=Module:TeamBracket-Tennis&amp;diff=610&amp;oldid=prev"/>
				<updated>2018-10-24T22:40:54Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 22:40, 24 October 2018&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.agency/index.php?title=Module:TeamBracket-Tennis&amp;diff=609&amp;oldid=prev</id>
		<title>Frietjes: fix</title>
		<link rel="alternate" type="text/html" href="https://wiki.agency/index.php?title=Module:TeamBracket-Tennis&amp;diff=609&amp;oldid=prev"/>
				<updated>2018-10-16T20:19:42Z</updated>
		
		<summary type="html">&lt;p&gt;fix&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--&lt;br /&gt;
-- This module implements many tennis bracket templates&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
local args = {}&lt;br /&gt;
local rounds&lt;br /&gt;
local sets = {}&lt;br /&gt;
local compact&lt;br /&gt;
local byes&lt;br /&gt;
local hideSeeds&lt;br /&gt;
local showSeeds&lt;br /&gt;
local hideHeadings&lt;br /&gt;
local showThird&lt;br /&gt;
local offsetThird&lt;br /&gt;
local compactFinal&lt;br /&gt;
local RD1seedmap = {}&lt;br /&gt;
local tcats = &amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
local function isnotblank(s)&lt;br /&gt;
	return s and s ~= &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function isblank(s)&lt;br /&gt;
	return (not s) or (s == &amp;#039;&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parseArgs(frame)&lt;br /&gt;
	local fargs = frame.args&lt;br /&gt;
	local pargs = frame:getParent().args;&lt;br /&gt;
&lt;br /&gt;
	local r = tonumber(fargs.rounds or &amp;#039;&amp;#039;) or tonumber(pargs.rounds or &amp;#039;&amp;#039;) or 2&lt;br /&gt;
	local teams = math.pow(2, r)&lt;br /&gt;
	local rdstr = &amp;#039;RD&amp;#039; .. tostring(r)&lt;br /&gt;
	local rdbstr = &amp;#039;RD&amp;#039; .. tostring(r) .. &amp;#039;b&amp;#039;&lt;br /&gt;
	local rdp1str = &amp;#039;RD&amp;#039; .. tostring(r+1)&lt;br /&gt;
&lt;br /&gt;
	for i=1,2 do&lt;br /&gt;
		local targs = (i == 1) and pargs or fargs&lt;br /&gt;
		for k,v in pairs(targs) do&lt;br /&gt;
			if type(k) == &amp;#039;string&amp;#039; then&lt;br /&gt;
				if k:find(&amp;#039;^[R3][Dr][d1-9]b?%-[a-z][a-z]*00*&amp;#039;) then&lt;br /&gt;
					k = mw.ustring.gsub(k, &amp;#039;^([R3][Dr][d1-9]b?%-[a-z][a-z]*)00*&amp;#039;, &amp;#039;%1&amp;#039;)&lt;br /&gt;
					if (teams &amp;lt; 10) then &lt;br /&gt;
						tcats = tcats .. &amp;#039;[[Category:Pages using a tennis bracket with deprecated syntax|P]]&amp;#039;&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
				if k:find(&amp;#039;^&amp;#039; .. rdp1str) then&lt;br /&gt;
					k = mw.ustring.gsub(k, &amp;#039;^&amp;#039; .. rdp1str, &amp;#039;3rd&amp;#039;)&lt;br /&gt;
					tcats = tcats .. &amp;#039;[[Category:Pages using a tennis bracket with deprecated syntax|3]]&amp;#039;&lt;br /&gt;
				elseif k:find(&amp;#039;^&amp;#039; .. rdbstr) then&lt;br /&gt;
					k = mw.ustring.gsub(k, &amp;#039;^&amp;#039; .. rdbstr, &amp;#039;3rd&amp;#039;)&lt;br /&gt;
				elseif k:find(&amp;#039;^&amp;#039; .. rdstr .. &amp;#039;%-[a-z][a-z]*3&amp;#039;) then&lt;br /&gt;
					k = mw.ustring.gsub(k, &amp;#039;^&amp;#039; .. rdstr .. &amp;#039;(%-[a-z][a-z]*)3&amp;#039;, &amp;#039;3rd%11&amp;#039;)&lt;br /&gt;
				elseif k:find(&amp;#039;^&amp;#039; .. rdstr .. &amp;#039;%-[a-z][a-z]*4&amp;#039;) then&lt;br /&gt;
					k = mw.ustring.gsub(k, &amp;#039;^&amp;#039; .. rdstr .. &amp;#039;(%-[a-z][a-z]*)4&amp;#039;, &amp;#039;3rd%12&amp;#039;)&lt;br /&gt;
				elseif  k:find(&amp;#039;^Consol&amp;#039;) then&lt;br /&gt;
					k = mw.ustring.gsub(k, &amp;#039;^Consol&amp;#039;, &amp;#039;3rd&amp;#039;)&lt;br /&gt;
					tcats = tcats .. &amp;#039;[[Category:Pages using a tennis bracket with deprecated syntax|3]]&amp;#039;&lt;br /&gt;
				elseif k:find(&amp;#039;^group[0-9]&amp;#039;) then&lt;br /&gt;
					tcats = tcats .. &amp;#039;[[Category:Pages using a tennis bracket with deprecated syntax|G]]&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			args[k] = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (args[&amp;#039;byes&amp;#039;] and (args[&amp;#039;byes&amp;#039;] == &amp;#039;yes&amp;#039; or args[&amp;#039;byes&amp;#039;] == &amp;#039;y&amp;#039;)) then&lt;br /&gt;
		tcats = tcats .. &amp;#039;[[Category:Pages using a tennis bracket with deprecated syntax|B]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parseSeedmap(s)&lt;br /&gt;
	s = mw.text.split((s or &amp;#039;0&amp;#039;) .. &amp;#039;/&amp;#039;, &amp;#039;[%s]*/[%s]*&amp;#039;)&lt;br /&gt;
	local teams = math.pow(2, rounds)&lt;br /&gt;
	for r=1,teams do&lt;br /&gt;
		RD1seedmap[r] = 1&lt;br /&gt;
	end&lt;br /&gt;
	for r=1,#s do&lt;br /&gt;
		if tonumber(s[r] or &amp;#039;x&amp;#039;) then&lt;br /&gt;
			RD1seedmap[tonumber(s[r])] = 0&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local c = 1&lt;br /&gt;
	for r=1,teams do&lt;br /&gt;
		if RD1seedmap[r] &amp;gt; 0 then&lt;br /&gt;
			RD1seedmap[r] = c&lt;br /&gt;
			c = c + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function parseSets(s)&lt;br /&gt;
	s = mw.text.split((s or &amp;#039;5&amp;#039;) .. &amp;#039;/&amp;#039;, &amp;#039;[%s]*/[%s]*&amp;#039;)&lt;br /&gt;
	local n = showThird and (rounds + 1) or (rounds)&lt;br /&gt;
	for r=1,n do&lt;br /&gt;
		if s[r] ~= nil and s[r] ~= &amp;#039;&amp;#039; and tonumber(s[r]) then&lt;br /&gt;
			sets[r] = tonumber(s[r])&lt;br /&gt;
		elseif sets[r-1] then&lt;br /&gt;
			sets[r] = sets[r-1]&lt;br /&gt;
		else&lt;br /&gt;
			sets[r] = 5&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function addTableRow(tbl)&lt;br /&gt;
	return tbl:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function addBlank(row, width)&lt;br /&gt;
	local cell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
	if width then&lt;br /&gt;
		cell:css(&amp;#039;width&amp;#039;, width)&lt;br /&gt;
	end&lt;br /&gt;
	return cell&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function addHeading(row, r, text)&lt;br /&gt;
	row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;colspan&amp;#039;, tonumber(hideSeeds and &amp;#039;1&amp;#039; or &amp;#039;2&amp;#039;) + sets[r])&lt;br /&gt;
		:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;border&amp;#039;, &amp;#039;1px solid #aaa&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;background-color&amp;#039;, args[&amp;#039;RD-shade&amp;#039;] or &amp;#039;#f2f2f2&amp;#039;)&lt;br /&gt;
		:wikitext(text)&lt;br /&gt;
		:newline()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getWidth(param, default)&lt;br /&gt;
	local arg = args[param .. &amp;#039;-width&amp;#039;]&lt;br /&gt;
	if isblank(arg) then&lt;br /&gt;
		arg = default&lt;br /&gt;
	end&lt;br /&gt;
	if tonumber(arg) ~= nil then&lt;br /&gt;
		arg = arg .. &amp;#039;px&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return arg&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getTeamArgName(round, type, team)&lt;br /&gt;
	if round &amp;gt; rounds then&lt;br /&gt;
		return string.format(&amp;#039;3rd-%s%d&amp;#039;, type, team)&lt;br /&gt;
	else&lt;br /&gt;
		if (round == 1) then&lt;br /&gt;
			team = RD1seedmap[team]&lt;br /&gt;
			if team == 0 then&lt;br /&gt;
				return &amp;#039;NIL&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return string.format(&amp;#039;RD%d-%s%d&amp;#039;, round, type, team)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getShadeArg(round, team, s)&lt;br /&gt;
	local argname = getTeamArgName(round, &amp;#039;shade&amp;#039;, team) .. (s and (&amp;#039;-&amp;#039; .. s) or &amp;#039;&amp;#039;)&lt;br /&gt;
	local value = args[argname]&lt;br /&gt;
	if isblank(value) then&lt;br /&gt;
		return &amp;#039;#f9f9f9&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getScoreArg(round, team, s)&lt;br /&gt;
	local argname = getTeamArgName(round, &amp;#039;score&amp;#039;, team) .. (s and (&amp;#039;-&amp;#039; .. s) or &amp;#039;&amp;#039;)&lt;br /&gt;
	local value = args[argname]&lt;br /&gt;
	if isblank(value) then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return value&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getTeamArg(round, type, team)&lt;br /&gt;
	local argname = getTeamArgName(round, type, team)&lt;br /&gt;
	local value = args[argname]&lt;br /&gt;
	if isblank(value) then&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if mw.ustring.find(value, &amp;#039;[%s]*&amp;lt;[%s/]*[Bb][Rr][%s/]*&amp;gt;[%s ]*&amp;amp;[Nn][Bb][Ss][Pp];[%s]*&amp;#039;) then&lt;br /&gt;
		tcats = &amp;#039;[[Category:Pages using a tennis bracket with nbsp]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return mw.ustring.gsub(value, &amp;#039;[%s]*&amp;lt;[%s/]*[Bb][Rr][%s/]*&amp;gt;[%s ]*&amp;amp;[Nn][Bb][Ss][Pp];[%s]*&amp;#039;, &amp;#039;&amp;lt;br/&amp;gt;&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function isHidden(r, team)&lt;br /&gt;
	return isblank( getTeamArg(r, &amp;#039;team&amp;#039;, team) )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getRoundName(round)&lt;br /&gt;
	local name = args[&amp;#039;RD&amp;#039; .. round]&lt;br /&gt;
	if isnotblank(name) then&lt;br /&gt;
		return name&lt;br /&gt;
	end&lt;br /&gt;
	local roundFromLast = rounds - round + 1&lt;br /&gt;
	if roundFromLast == 1 then&lt;br /&gt;
		return &amp;quot;Finals&amp;quot;&lt;br /&gt;
	elseif roundFromLast == 2 then&lt;br /&gt;
		return &amp;quot;Semifinals&amp;quot;&lt;br /&gt;
	elseif roundFromLast == 3 then&lt;br /&gt;
		return &amp;quot;Quarterfinals&amp;quot;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;Round of &amp;quot; .. math.pow(2, roundFromLast)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function addPath(rows, index, round, top, left, w)&lt;br /&gt;
	local prop = top and &amp;#039;border-bottom-width&amp;#039; or &amp;#039;border-top-width&amp;#039;&lt;br /&gt;
	if left and round == 1 then&lt;br /&gt;
		if compact then&lt;br /&gt;
			addBlank(rows[index])&lt;br /&gt;
		else&lt;br /&gt;
			addBlank(rows[index]):css(&amp;#039;height&amp;#039;, &amp;#039;7px&amp;#039;)&lt;br /&gt;
			addBlank(rows[index + 1]):css(&amp;#039;height&amp;#039;, &amp;#039;7px&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		return nil&lt;br /&gt;
	else&lt;br /&gt;
		local cell = addBlank(rows[index])&lt;br /&gt;
			:attr(&amp;#039;rowspan&amp;#039;, (not compact) and &amp;#039;2&amp;#039; or nil)&lt;br /&gt;
			:css(&amp;#039;border-width&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-style&amp;#039;, &amp;#039;solid&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-color&amp;#039;, &amp;#039;black&amp;#039;)&lt;br /&gt;
		if left or round &amp;lt; rounds and not left then&lt;br /&gt;
			cell:css(prop, w or &amp;#039;2px&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		return cell&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderTeam(row, round, team, top, otherbye)&lt;br /&gt;
	local seedCell&lt;br /&gt;
	local seedArg = getTeamArg(round, &amp;#039;seed&amp;#039;, team)&lt;br /&gt;
	-- seed value for the paired team&lt;br /&gt;
	local pairSeedArg = otherbye and &amp;#039;&amp;#039; &lt;br /&gt;
		or getTeamArg(round, &amp;#039;seed&amp;#039;, team % 2 == 0 and team-1 or team+1)&lt;br /&gt;
	-- show seed if seed is defined for either or both&lt;br /&gt;
	local showSeed = showSeeds&lt;br /&gt;
		or isnotblank(seedArg)&lt;br /&gt;
		or isnotblank(pairSeedArg)&lt;br /&gt;
	if showSeed and (not hideSeeds) then&lt;br /&gt;
		seedCell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;background-color&amp;#039;, &amp;#039;#f2f2f2&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border&amp;#039;, &amp;#039;1px solid #aaa&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-top-width&amp;#039;, (top or otherbye) and &amp;#039;1px&amp;#039; or &amp;#039;0&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;rowspan&amp;#039;, (not compact) and &amp;#039;2&amp;#039; or nil)&lt;br /&gt;
			:wikitext(seedArg)&lt;br /&gt;
			:newline()&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local teamArg = getTeamArg(round, &amp;#039;team&amp;#039;, team)&lt;br /&gt;
	if isblank(teamArg) then&lt;br /&gt;
		teamArg = &amp;#039;&amp;amp;nbsp;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local teamCell = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;background-color&amp;#039;, &amp;#039;#f9f9f9&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;border&amp;#039;, &amp;#039;1px solid #aaa&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;border-top-width&amp;#039;, (top or otherbye) and &amp;#039;1px&amp;#039; or &amp;#039;0&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;padding&amp;#039;, &amp;#039;0 2px&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;rowspan&amp;#039;, (not compact) and &amp;#039;2&amp;#039; or nil)&lt;br /&gt;
		:wikitext(teamArg)&lt;br /&gt;
		:newline()&lt;br /&gt;
	if not showSeed and (not hideSeeds) then&lt;br /&gt;
		teamCell:attr(&amp;#039;colspan&amp;#039;, &amp;#039;2&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local scoreCells = {}&lt;br /&gt;
	for s = 1, sets[round] do&lt;br /&gt;
		scoreCells[s] = row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-color&amp;#039;, &amp;#039;#aaa&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-style&amp;#039;, &amp;#039;solid&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-top-width&amp;#039;, (top or otherbye) and &amp;#039;1px&amp;#039; or &amp;#039;0&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-left-width&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-right-width&amp;#039;, &amp;#039;1px&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-bottom-width&amp;#039;, &amp;#039;1px&amp;#039;)	&lt;br /&gt;
			:css(&amp;#039;background-color&amp;#039;, getShadeArg(round, team, s))&lt;br /&gt;
			:attr(&amp;#039;rowspan&amp;#039;, (not compact) and &amp;#039;2&amp;#039; or nil)&lt;br /&gt;
			:wikitext(getScoreArg(round, team, s))&lt;br /&gt;
			:newline()&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderRound(rows, count, r)&lt;br /&gt;
	local teams = math.pow(2, rounds - r + 1)&lt;br /&gt;
	local step = count / teams&lt;br /&gt;
	local topTeam = true -- is top row in match-up&lt;br /&gt;
	local topPair = true -- is top match-up in pair of match-ups&lt;br /&gt;
	local team = 1&lt;br /&gt;
&lt;br /&gt;
	for i = 1, count, step do&lt;br /&gt;
		local offset, height, blank&lt;br /&gt;
&lt;br /&gt;
		local hideteam = false&lt;br /&gt;
		local otherhideteam = false&lt;br /&gt;
		local hideleftpath = false&lt;br /&gt;
		if r &amp;lt;= byes then&lt;br /&gt;
			hideteam = isHidden(r, team)&lt;br /&gt;
			otherhideteam = isHidden(r, team % 2 == 0 and team-1 or team+1)&lt;br /&gt;
		end&lt;br /&gt;
		if (r == 1) and (RD1seedmap[team] &amp;lt;= 0) then&lt;br /&gt;
				hideteam = true&lt;br /&gt;
		end&lt;br /&gt;
		if (r &amp;gt; 1) and (r &amp;lt;= (byes + 1)) then&lt;br /&gt;
			hideleftpath = isHidden(r-1, 2*team-1) and isHidden(r-1, 2*team)&lt;br /&gt;
		end&lt;br /&gt;
		if (r == 2) and (RD1seedmap[2*team-1] &amp;lt;= 0 and RD1seedmap[2*team] &amp;lt;= 0) then&lt;br /&gt;
			hideleftpath = true&lt;br /&gt;
		end&lt;br /&gt;
		if compactFinal and (r == rounds) then&lt;br /&gt;
			hideleftpath = true&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		-- empty space above or below&lt;br /&gt;
		if compact then&lt;br /&gt;
			offset = topTeam and i or i + 1&lt;br /&gt;
			height = step - 1&lt;br /&gt;
		-- leave room for groups for teams other than first and last&lt;br /&gt;
		elseif team == 1 or team == teams then&lt;br /&gt;
			offset = topTeam and i or i + 2&lt;br /&gt;
			height = step - 2&lt;br /&gt;
		else&lt;br /&gt;
			offset = topTeam and i + 1 or i + 2&lt;br /&gt;
			height = step - 3&lt;br /&gt;
		end&lt;br /&gt;
		if showThird and (r == rounds) and (not topTeam) then&lt;br /&gt;
			height = offset - offsetThird&lt;br /&gt;
		end&lt;br /&gt;
		if compactFinal and (r == (rounds - 1)) then&lt;br /&gt;
			if team == 2 then&lt;br /&gt;
				height = height - 3&lt;br /&gt;
			end&lt;br /&gt;
			if team == 3 then&lt;br /&gt;
				height = height - 1&lt;br /&gt;
				offset = offset + 1&lt;br /&gt;
				rows[offset-3]:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
					:attr(&amp;#039;colspan&amp;#039;, tonumber(hideSeeds and &amp;#039;2&amp;#039; or &amp;#039;3&amp;#039;) + sets[r])&lt;br /&gt;
				rows[offset-4]:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				addHeading(rows[offset-4], r + 1, getRoundName(r+1))&lt;br /&gt;
				rows[offset-4]:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
					:attr(&amp;#039;rowspan&amp;#039;, 2)&lt;br /&gt;
					:css(&amp;#039;border-color&amp;#039;, &amp;#039;black&amp;#039;)&lt;br /&gt;
					:css(&amp;#039;border-style&amp;#039;, &amp;#039;solid&amp;#039;)&lt;br /&gt;
					:css(&amp;#039;border-width&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
					:css(&amp;#039;border-right-width&amp;#039;, &amp;#039;2px&amp;#039;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if height &amp;gt; 0 then&lt;br /&gt;
			blank = addBlank(rows[offset])&lt;br /&gt;
				:attr(&amp;#039;colspan&amp;#039;, tonumber(hideSeeds and &amp;#039;3&amp;#039; or &amp;#039;4&amp;#039;) + sets[r])&lt;br /&gt;
				:attr(&amp;#039;rowspan&amp;#039;, height)&lt;br /&gt;
				:css(&amp;#039;border-color&amp;#039;, &amp;#039;black&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;border-style&amp;#039;, &amp;#039;solid&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;border-width&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		-- add bracket&lt;br /&gt;
		local j = topTeam and i + step - (compact and 1 or 2) or i&lt;br /&gt;
		-- add left path&lt;br /&gt;
		addPath(rows, j, r, topTeam, true, hideleftpath and &amp;#039;0&amp;#039; or &amp;#039;2px&amp;#039;)&lt;br /&gt;
		if hideteam then&lt;br /&gt;
			rows[j]:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:attr(&amp;#039;colspan&amp;#039;, tonumber(hideSeeds and &amp;#039;1&amp;#039; or &amp;#039;2&amp;#039;) + sets[r])&lt;br /&gt;
				:attr(&amp;#039;rowspan&amp;#039;, (not compact) and 2 or nil)&lt;br /&gt;
		else&lt;br /&gt;
			renderTeam(rows[j], r, team, topTeam, otherhideteam)&lt;br /&gt;
		end&lt;br /&gt;
		local rightPath = addPath(rows, j, r, topTeam, false, hideteam and &amp;#039;0&amp;#039; or &amp;#039;2px&amp;#039;)&lt;br /&gt;
		if not topTeam then topPair = not topPair end&lt;br /&gt;
		if not topPair and r &amp;lt; rounds and (not hideteam) then&lt;br /&gt;
			if blank then blank:css(&amp;#039;border-right-width&amp;#039;, &amp;#039;2px&amp;#039;) end&lt;br /&gt;
			rightPath:css(&amp;#039;border-right-width&amp;#039;, &amp;#039;2px&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		if compactFinal and (r == rounds) then&lt;br /&gt;
			local prop = (team == 1) and &amp;#039;border-bottom-width&amp;#039; or &amp;#039;border-top-width&amp;#039;&lt;br /&gt;
			rightPath:css(&amp;#039;border-right-width&amp;#039;, &amp;#039;2px&amp;#039;)&lt;br /&gt;
				:css(prop, &amp;#039;2px&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		team = team + 1&lt;br /&gt;
		topTeam = not topTeam&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderGroups(rows, count, round)&lt;br /&gt;
	local roundFromLast = rounds - round + 1&lt;br /&gt;
	local groups = math.pow(2, roundFromLast - 2)&lt;br /&gt;
	local step = count / groups&lt;br /&gt;
	local group = 1&lt;br /&gt;
	local offset = 0&lt;br /&gt;
	local team = 0&lt;br /&gt;
	local w = &amp;#039;2px&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	for r = 1,round do&lt;br /&gt;
		offset = offset + (hideSeeds and 3 or 4) + sets[r]&lt;br /&gt;
	end&lt;br /&gt;
	for i = step / 2, count, step do&lt;br /&gt;
		local name = &amp;#039;RD&amp;#039; .. round .. &amp;#039;-group&amp;#039; .. group&lt;br /&gt;
		addBlank(rows[i]):css(&amp;#039;height&amp;#039;, &amp;#039;7px&amp;#039;)&lt;br /&gt;
		addBlank(rows[i + 1]):css(&amp;#039;height&amp;#039;, &amp;#039;7px&amp;#039;)&lt;br /&gt;
		addBlank(rows[i])&lt;br /&gt;
			:attr(&amp;#039;rowspan&amp;#039;, &amp;#039;2&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;colspan&amp;#039;, offset - 2)&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
			:wikitext(args[name])&lt;br /&gt;
			:newline()&lt;br /&gt;
		if (round &amp;lt;= byes) then&lt;br /&gt;
			team = i/(step/2)&lt;br /&gt;
			w = isHidden(round, 2*team-1) and isHidden(round, 2*team) and &amp;#039;0&amp;#039; or &amp;#039;2px&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		addBlank(rows[i])&lt;br /&gt;
			:css(&amp;#039;border-color&amp;#039;, &amp;#039;black&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-style&amp;#039;, &amp;#039;solid&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-width&amp;#039;, &amp;#039;0 &amp;#039; .. w .. &amp;#039; 0 0&amp;#039;)&lt;br /&gt;
		if (round &amp;lt;= byes) then&lt;br /&gt;
			team = team + 1&lt;br /&gt;
			w = isHidden(round, 2*team-1) and isHidden(round, 2*team) and &amp;#039;0&amp;#039; or &amp;#039;2px&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		addBlank(rows[i+1])&lt;br /&gt;
			:css(&amp;#039;border-color&amp;#039;, &amp;#039;black&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-style&amp;#039;, &amp;#039;solid&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;border-width&amp;#039;, &amp;#039;0 &amp;#039; .. w ..&amp;#039; 0 0&amp;#039;)&lt;br /&gt;
		group = group + 1&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function getThirdOffset()&lt;br /&gt;
	local offset = (compact and 1 or 3) * (math.pow(2, rounds) - math.pow(2, rounds-3)) - (compact and 2 or 4)&lt;br /&gt;
	if rounds &amp;lt; 4 then&lt;br /&gt;
		offset = compact and 8 or 17&lt;br /&gt;
		if rounds &amp;lt; 3 then&lt;br /&gt;
			offset = compact and 6 or 10&lt;br /&gt;
			if rounds &amp;lt; 2 then&lt;br /&gt;
				offset = compact and 4 or 6&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return offset&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderThird(rows, count)&lt;br /&gt;
	local k = offsetThird&lt;br /&gt;
	local row = rows[k]&lt;br /&gt;
	local blank&lt;br /&gt;
	--if (offsetThird &amp;lt; count) then&lt;br /&gt;
		--blank = addBlank(row)&lt;br /&gt;
		--blank:attr(&amp;#039;colspan&amp;#039;, tonumber(hideSeeds and &amp;#039;3&amp;#039; or &amp;#039;4&amp;#039;) + sets[1])&lt;br /&gt;
	--end&lt;br /&gt;
	blank = addBlank(row)&lt;br /&gt;
	addHeading(row, rounds + 1, args[&amp;#039;3rd&amp;#039;] or &amp;#039;Third place&amp;#039;)&lt;br /&gt;
	k = k + (compact and 2 or 3)&lt;br /&gt;
	for i = 1,2 do&lt;br /&gt;
		row = rows[k]&lt;br /&gt;
		blank = addBlank(row)&lt;br /&gt;
		renderTeam(row, rounds + 1, i, i == 1, false)&lt;br /&gt;
		k = k + (compact and 1 or 2)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderTree(tbl)&lt;br /&gt;
	-- create 3 or 1 rows for every team&lt;br /&gt;
	local count = math.pow(2, rounds) * (compact and 1 or 3)&lt;br /&gt;
	local offsetcount = 2 * (compact and 1 or 3) + (compact and 2 or 3)&lt;br /&gt;
	local rows = {}&lt;br /&gt;
	offsetThird = getThirdOffset()&lt;br /&gt;
	for i = 1, count do&lt;br /&gt;
		rows[i] = addTableRow(tbl)&lt;br /&gt;
	end&lt;br /&gt;
	if showThird then&lt;br /&gt;
		for i = (count+1), (offsetcount + offsetThird) do&lt;br /&gt;
			rows[i] = addTableRow(tbl)&lt;br /&gt;
			if (rounds &amp;gt; 1) then&lt;br /&gt;
				local blank = addBlank(rows[i])&lt;br /&gt;
				blank:attr(&amp;#039;colspan&amp;#039;, tonumber(hideSeeds and &amp;#039;3&amp;#039; or &amp;#039;4&amp;#039;) + sets[1])&lt;br /&gt;
				if compact and (rounds &amp;gt; 2) then&lt;br /&gt;
					blank = addBlank(rows[i])&lt;br /&gt;
					blank:attr(&amp;#039;colspan&amp;#039;, tonumber(hideSeeds and &amp;#039;3&amp;#039; or &amp;#039;4&amp;#039;) + sets[1])&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if not compact then&lt;br /&gt;
		-- fill rows with groups&lt;br /&gt;
		for r = 1, rounds - 1 do&lt;br /&gt;
			renderGroups(rows, count, r)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- fill rows with bracket&lt;br /&gt;
	for r = 1, rounds do&lt;br /&gt;
		renderRound(rows, count, r)&lt;br /&gt;
	end&lt;br /&gt;
	if showThird then&lt;br /&gt;
		renderThird(rows, count, compact)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderHeadings(tbl)&lt;br /&gt;
	local titleRow = addTableRow((not hideHeadings) and tbl or mw.html.create(&amp;#039;table&amp;#039;))&lt;br /&gt;
	local widthRow = addTableRow(tbl)&lt;br /&gt;
	for r = 1, (compactFinal and (rounds-1) or rounds) do&lt;br /&gt;
		addBlank(titleRow)&lt;br /&gt;
		addBlank(widthRow, r &amp;gt; 1 and &amp;#039;5px&amp;#039; or &amp;#039;1px&amp;#039;)&lt;br /&gt;
		addHeading(titleRow, r, getRoundName(r) )&lt;br /&gt;
		local seedCell&lt;br /&gt;
		if (not hideSeeds) then&lt;br /&gt;
			seedCell = addBlank(widthRow, getWidth(&amp;#039;seed&amp;#039;, &amp;#039;25px&amp;#039;))&lt;br /&gt;
		end&lt;br /&gt;
		local teamCell = addBlank(widthRow, getWidth(&amp;#039;team&amp;#039;, &amp;#039;150px&amp;#039;))&lt;br /&gt;
		local scoreCells = {}&lt;br /&gt;
		for s = 1, sets[r] do&lt;br /&gt;
			scoreCells[s] = addBlank(widthRow, getWidth(&amp;#039;score&amp;#039;, &amp;#039;12px&amp;#039;))&lt;br /&gt;
		end&lt;br /&gt;
		addBlank(titleRow)&lt;br /&gt;
		addBlank(widthRow, r &amp;lt; rounds and &amp;#039;5px&amp;#039; or &amp;#039;1px&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
		if compact then&lt;br /&gt;
			teamCell:css(&amp;#039;height&amp;#039;, &amp;#039;7px&amp;#039;)&lt;br /&gt;
		else&lt;br /&gt;
			if seedCell then&lt;br /&gt;
				seedCell:wikitext(&amp;#039;&amp;amp;nbsp;&amp;#039;)&lt;br /&gt;
			end&lt;br /&gt;
			teamCell:wikitext(&amp;#039;&amp;amp;nbsp;&amp;#039;)&lt;br /&gt;
			for s = 1, sets[r] do&lt;br /&gt;
				scoreCells[s]:wikitext(&amp;#039;&amp;amp;nbsp;&amp;#039;)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.teamBracket(frame)&lt;br /&gt;
	parseArgs(frame)&lt;br /&gt;
	rounds = tonumber(args.rounds) or 2&lt;br /&gt;
	local teams = math.pow(2, rounds)&lt;br /&gt;
	compact = (args[&amp;#039;compact&amp;#039;] and (args[&amp;#039;compact&amp;#039;] == &amp;#039;yes&amp;#039; or args[&amp;#039;compact&amp;#039;] == &amp;#039;y&amp;#039;))&lt;br /&gt;
	compactFinal = ((rounds &amp;gt; 4) and compact and args[&amp;#039;compact-final&amp;#039;] and (args[&amp;#039;compact-final&amp;#039;] == &amp;#039;yes&amp;#039; or args[&amp;#039;compact-final&amp;#039;] == &amp;#039;y&amp;#039;))&lt;br /&gt;
	hideSeeds = (args[&amp;#039;seeds&amp;#039;] and (args[&amp;#039;seeds&amp;#039;] == &amp;#039;no&amp;#039; or args[&amp;#039;seeds&amp;#039;] == &amp;#039;n&amp;#039;))&lt;br /&gt;
	showSeeds = (args[&amp;#039;seeds&amp;#039;] and (args[&amp;#039;seeds&amp;#039;] == &amp;#039;yes&amp;#039; or args[&amp;#039;seeds&amp;#039;] == &amp;#039;y&amp;#039;))&lt;br /&gt;
	byes = (args[&amp;#039;byes&amp;#039;] and (args[&amp;#039;byes&amp;#039;] == &amp;#039;yes&amp;#039; or args[&amp;#039;byes&amp;#039;] == &amp;#039;y&amp;#039;) and 1) or (tonumber(args[&amp;#039;byes&amp;#039;] or &amp;#039;0&amp;#039;) or 0)&lt;br /&gt;
	hideHeadings = (args[&amp;#039;headings&amp;#039;] and (args[&amp;#039;headings&amp;#039;] == &amp;#039;no&amp;#039; or args[&amp;#039;headings&amp;#039;] == &amp;#039;n&amp;#039;))&lt;br /&gt;
	showThird = isnotblank(args[&amp;#039;3rd&amp;#039;]) or isnotblank(args[&amp;#039;3rd-team1&amp;#039;]) or isnotblank(args[&amp;#039;3rd-team2&amp;#039;])&lt;br /&gt;
	parseSeedmap(args[&amp;#039;RD1-omit&amp;#039;])&lt;br /&gt;
	parseSets(args.sets)&lt;br /&gt;
&lt;br /&gt;
	-- create the table&lt;br /&gt;
	local tbl = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;border-style&amp;#039;, &amp;#039;none&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;font-size&amp;#039;, &amp;#039;90%&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;margin&amp;#039;, &amp;#039;1em 2em 1em 1em&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;border-collapse&amp;#039;, &amp;#039;separate&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;border-spacing&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;cellpadding&amp;#039;, &amp;#039;0&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
	if (args[&amp;#039;nowrap&amp;#039;] and (args[&amp;#039;nowrap&amp;#039;] == &amp;#039;yes&amp;#039; or args[&amp;#039;nowrap&amp;#039;] == &amp;#039;y&amp;#039;)) then&lt;br /&gt;
		tbl:css(&amp;#039;white-space&amp;#039;, &amp;#039;nowrap&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	renderHeadings(tbl)&lt;br /&gt;
	renderTree(tbl)&lt;br /&gt;
	return tostring(tbl) .. tcats&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Frietjes</name></author>	</entry>

	</feed>