<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://escforumwiki.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ASports_table</id>
	<title>Module:Sports table - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://escforumwiki.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ASports_table"/>
	<link rel="alternate" type="text/html" href="https://escforumwiki.com/index.php?title=Module:Sports_table&amp;action=history"/>
	<updated>2026-04-03T22:04:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://escforumwiki.com/index.php?title=Module:Sports_table&amp;diff=57658&amp;oldid=prev</id>
		<title>TheMooCows: Created page with &quot;-- Module to build tables for standings in Sports -- See documentation for details  require(&#039;Module:No globals&#039;)  local p = {}  -- Helper functions local function isnotblank(s...&quot;</title>
		<link rel="alternate" type="text/html" href="https://escforumwiki.com/index.php?title=Module:Sports_table&amp;diff=57658&amp;oldid=prev"/>
		<updated>2016-08-18T08:22:22Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;-- Module to build tables for standings in Sports -- See documentation for details  require(&amp;#039;Module:No globals&amp;#039;)  local p = {}  -- Helper functions local function isnotblank(s...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Module to build tables for standings in Sports&lt;br /&gt;
-- See documentation for details&lt;br /&gt;
&lt;br /&gt;
require(&amp;#039;Module:No globals&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Helper functions&lt;br /&gt;
local function isnotblank(s)&lt;br /&gt;
	return s and s:match( &amp;#039;^%s*(.-)%s*$&amp;#039; ) ~= &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function firstnonblank(s1,s2)&lt;br /&gt;
	if ( s1 and s1:match( &amp;#039;^%s*(.-)%s*$&amp;#039; ) ~= &amp;#039;&amp;#039; ) then&lt;br /&gt;
		return s1&lt;br /&gt;
	elseif ( s2 and s2:match( &amp;#039;^%s*(.-)%s*$&amp;#039; ) ~= &amp;#039;&amp;#039; ) then&lt;br /&gt;
		return s2&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
-- Main function&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	-- Declare locals&lt;br /&gt;
	local Args = frame.args&lt;br /&gt;
	local Pargs = frame:getParent().args&lt;br /&gt;
	local ii_start, ii_end, N_rows_res = 0&lt;br /&gt;
	local text_field_result&lt;br /&gt;
	local notes_exist = false&lt;br /&gt;
	local t = {}&lt;br /&gt;
	local t_footer = {}&lt;br /&gt;
	local t_return = {}&lt;br /&gt;
	local team_list = {}&lt;br /&gt;
	local jj, jjj&lt;br /&gt;
	&lt;br /&gt;
	-- Exit early if we are using section transclusion for a different section&lt;br /&gt;
	if( isnotblank(Pargs[&amp;#039;transcludesection&amp;#039;]) and isnotblank(Args[&amp;#039;section&amp;#039;]) ) then&lt;br /&gt;
		if( Pargs[&amp;#039;transcludesection&amp;#039;] ~= Args[&amp;#039;section&amp;#039;] ) then&lt;br /&gt;
			return &amp;#039;&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Get the custom start point for the table (most will start by default at 1&lt;br /&gt;
	local top_pos = tonumber(Args[&amp;#039;highest_pos&amp;#039;]) or 1&lt;br /&gt;
	local N_teams = top_pos - 1 -- Default to 0 at start, but higher number needed to skip certain entries&lt;br /&gt;
	&lt;br /&gt;
	-- Load modules&lt;br /&gt;
	local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
	-- Load style and (sub) modules&lt;br /&gt;
	local style_def = Args[&amp;#039;style&amp;#039;] or &amp;#039;WDL&amp;#039;&lt;br /&gt;
	-- Historically &amp;#039;football&amp;#039; exists as style, this is now forwarded to WDL&lt;br /&gt;
	if style_def == &amp;#039;football&amp;#039; then style_def = &amp;#039;WDL&amp;#039; end&lt;br /&gt;
	local p_style = require(&amp;#039;Module:Sports table/&amp;#039;..style_def)&lt;br /&gt;
	local p_sub = require(&amp;#039;Module:Sports table/sub&amp;#039;)&lt;br /&gt;
	local p_matches = require(&amp;#039;Module:Sports results&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	-- Random value used for uniqueness&lt;br /&gt;
	math.randomseed( os.clock() * 10^8 )&lt;br /&gt;
	local rand_val = math.random()&lt;br /&gt;
	&lt;br /&gt;
	-- Declare colour scheme&lt;br /&gt;
	local result_col = {}&lt;br /&gt;
	result_col = {green1=&amp;#039;#BBF3BB&amp;#039;, green2=&amp;#039;#CCF9CC&amp;#039;, green3=&amp;#039;#DDFCDD&amp;#039;, green4=&amp;#039;#EEFFEE&amp;#039;,&lt;br /&gt;
		blue1=&amp;#039;#BBF3FF&amp;#039;, blue2=&amp;#039;#CCF9FF&amp;#039;, blue3=&amp;#039;#DDFCFF&amp;#039;, blue4=&amp;#039;#EEFFFF&amp;#039;,&lt;br /&gt;
		yellow1=&amp;#039;#FFFFBB&amp;#039;, yellow2=&amp;#039;#FFFFCC&amp;#039;, yellow3=&amp;#039;#FFFFDD&amp;#039;, yellow4=&amp;#039;#FFFFEE&amp;#039;,&lt;br /&gt;
		red1=&amp;#039;#FFBBBB&amp;#039;, red2=&amp;#039;#FFCCCC&amp;#039;, red3=&amp;#039;#FFDDDD&amp;#039;, red4=&amp;#039;#FFEEEE&amp;#039;,&lt;br /&gt;
		black1=&amp;#039;#BBBBBB&amp;#039;, black2=&amp;#039;#CCCCCC&amp;#039;, black3=&amp;#039;#DDDDDD&amp;#039;, black4=&amp;#039;#EEEEEE&amp;#039;}&lt;br /&gt;
	&lt;br /&gt;
	-- Declare results column header&lt;br /&gt;
	local results_header = {}&lt;br /&gt;
	results_header = {Q=&amp;#039;Qualification&amp;#039;, QR=&amp;#039;Qualification or relegation&amp;#039;,&lt;br /&gt;
		P=&amp;#039;Promotion&amp;#039;, PQR=&amp;#039;Promotion, qualification or relegation&amp;#039;,&lt;br /&gt;
		PR=&amp;#039;Promotion or relegation&amp;#039;, PQ=&amp;#039;Promotion or qualification&amp;#039;, &lt;br /&gt;
		R=&amp;#039;Relegation&amp;#039;}&lt;br /&gt;
	local results_defined = false -- Check whether this would be needed&lt;br /&gt;
	-- Now define line for column header (either option or custom)&lt;br /&gt;
	local local_res_header = results_header[Args[&amp;#039;res_col_header&amp;#039;]] or Args[&amp;#039;res_col_header&amp;#039;]  or &amp;#039;&amp;#039;&lt;br /&gt;
	-- Check whether it includes a note&lt;br /&gt;
	local res_head_note = Args[&amp;#039;note_header_res&amp;#039;]&lt;br /&gt;
	local res_head_note_text = &amp;#039;&amp;#039;&lt;br /&gt;
	if res_head_note then&lt;br /&gt;
		notes_exist = true&lt;br /&gt;
		res_head_note_text = frame:expandTemplate{ title = &amp;#039;efn&amp;#039;, args = { group=&amp;#039;Table_notes&amp;#039;,  res_head_note} }&lt;br /&gt;
	end&lt;br /&gt;
	local results_header_txt = &amp;#039;! scope=&amp;quot;col&amp;quot; |&amp;#039;..local_res_header..res_head_note_text..&amp;#039;\n&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	-- Get status option&lt;br /&gt;
	local t_status = p_style.status(Args)&lt;br /&gt;
	&lt;br /&gt;
	-- Read in number of consecutive teams (ignore entries after skipping a spot)&lt;br /&gt;
	while Args[&amp;#039;team&amp;#039;..N_teams+1] ~= nil do&lt;br /&gt;
		N_teams = N_teams+1&lt;br /&gt;
		-- Sneakily add it twice to the team_list parameter, once for the actual&lt;br /&gt;
		-- ranking, the second for position lookup in sub-tables&lt;br /&gt;
		-- This is possible because Lua allows both numbers and strings as indices.&lt;br /&gt;
		team_list[N_teams] = Args[&amp;#039;team&amp;#039;..N_teams] -- i^th entry is team X&lt;br /&gt;
		team_list[Args[&amp;#039;team&amp;#039;..N_teams]] = N_teams -- team X entry is position i&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Show all stats in table or just matches played and points&lt;br /&gt;
	local pld_pts_val = firstnonblank(Pargs[&amp;#039;only_pld_pts&amp;#039;], Args[&amp;#039;only_pld_pts&amp;#039;]) or &amp;#039;no&amp;#039;&lt;br /&gt;
	local full_table&lt;br /&gt;
	local hide_class_rules = false&lt;br /&gt;
	-- True if par doesn&amp;#039;t exist, false otherwise&lt;br /&gt;
	-- First convert to lower case if it is a string&lt;br /&gt;
	pld_pts_val = string.lower(pld_pts_val)&lt;br /&gt;
	if yesno(pld_pts_val) then&lt;br /&gt;
		full_table = false&lt;br /&gt;
	elseif pld_pts_val==&amp;#039;no_hide_class_rules&amp;#039; then&lt;br /&gt;
		full_table = true&lt;br /&gt;
		hide_class_rules = true&lt;br /&gt;
	else&lt;br /&gt;
		full_table = true&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Show groups or note&lt;br /&gt;
	local show_groups_val = firstnonblank(Pargs[&amp;#039;show_groups&amp;#039;], Args[&amp;#039;show_groups&amp;#039;]) or &amp;#039;no&amp;#039;&lt;br /&gt;
	local group_col = false&lt;br /&gt;
	if yesno(show_groups_val) then group_col = true end&lt;br /&gt;
	&lt;br /&gt;
	-- Show match_table or not&lt;br /&gt;
	local show_matches_val = firstnonblank(Pargs[&amp;#039;show_matches&amp;#039;], Args[&amp;#039;show_matches&amp;#039;]) or &amp;#039;no&amp;#039;&lt;br /&gt;
	local match_table = false&lt;br /&gt;
	if yesno(show_matches_val) then match_table = true end&lt;br /&gt;
	&lt;br /&gt;
	-- Custom position column label or note&lt;br /&gt;
	local pos_label = Args[&amp;#039;postitle&amp;#039;] or &amp;#039;&amp;#039;&lt;br /&gt;
	if pos_label == &amp;#039;&amp;#039; then&lt;br /&gt;
		-- If empty (or undeclared) then default&lt;br /&gt;
		pos_label = &amp;#039;&amp;lt;abbr title=&amp;quot;Position&amp;quot;&amp;gt;Pos&amp;lt;/abbr&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Get VTE button text (but only for non-empty text)&lt;br /&gt;
	local template_name = Args[&amp;#039;template_name&amp;#039;] or &amp;#039;&amp;#039;&lt;br /&gt;
	local VTE_text = &amp;#039;&amp;#039;&lt;br /&gt;
	if template_name~=&amp;#039;&amp;#039; then&lt;br /&gt;
		VTE_text = frame:expandTemplate{ title = &amp;#039;navbar&amp;#039;, args = { mini=1, style=&amp;#039;float:right&amp;#039;,  template_name} }&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Write column headers&lt;br /&gt;
	t_return = p_style.header(t,Args,p_sub,pos_label,group_col,VTE_text,full_table,results_header_txt)&lt;br /&gt;
	if match_table then&lt;br /&gt;
		-- Add empty column header&lt;br /&gt;
		t_return.count = t_return.count+1&lt;br /&gt;
		table.insert(t_return.tab_text,&amp;#039;! scope=&amp;quot;row&amp;quot; class=&amp;quot;unsortable&amp;quot; style=&amp;quot;background-color:white;border-top:white;border-bottom:white;line-width:3pt;&amp;quot;| \n&amp;#039;)&lt;br /&gt;
		&lt;br /&gt;
		-- Add rest of header&lt;br /&gt;
		t_return = p_matches.header(t_return,Args,p_sub,N_teams,team_list)&lt;br /&gt;
	end&lt;br /&gt;
	t = t_return.tab_text&lt;br /&gt;
	local N_cols = t_return.count&lt;br /&gt;
	&lt;br /&gt;
	-- Determine what entries go into table&lt;br /&gt;
	-- Find out which team to show (if any)&lt;br /&gt;
	local ii_show = team_list[firstnonblank(Pargs[&amp;#039;showteam&amp;#039;], Args[&amp;#039;showteam&amp;#039;])] -- nil if non-existant&lt;br /&gt;
	-- Start and end positions to show&lt;br /&gt;
	local n_to_show = tonumber(Args[&amp;#039;show_limit&amp;#039;]) or N_teams&lt;br /&gt;
	-- Check for &amp;quot;legal value&amp;quot;, if not legal (or non declared), then show all&lt;br /&gt;
	local check_n = ((n_to_show&amp;gt;=(N_teams-top_pos+1)) or (n_to_show&amp;lt;=1) or (n_to_show~=math.floor(n_to_show)))&lt;br /&gt;
	-- Also check whether there is a valid ii_show&lt;br /&gt;
	if check_n or (not ii_show) then&lt;br /&gt;
		ii_start = top_pos&lt;br /&gt;
		ii_end = N_teams&lt;br /&gt;
	else&lt;br /&gt;
		-- It&amp;#039;s a proper integer between top_pos+1 and N_teams-1&lt;br /&gt;
		-- If it is in the middle show the same number above and below&lt;br /&gt;
		-- If it is in the top or bottom, show the exact number&lt;br /&gt;
		-- How many to show on the side&lt;br /&gt;
		local n_show_side = math.floor(n_to_show/2)&lt;br /&gt;
		if (ii_show-top_pos+1)&amp;lt;=n_show_side then&lt;br /&gt;
			-- Top team&lt;br /&gt;
			ii_start = top_pos&lt;br /&gt;
			ii_end = top_pos+n_to_show-1&lt;br /&gt;
		elseif ii_show&amp;gt;=(N_teams+1-n_show_side) then&lt;br /&gt;
			-- Bottom team&lt;br /&gt;
			ii_start = N_teams+1-n_to_show&lt;br /&gt;
			ii_end = N_teams&lt;br /&gt;
		else&lt;br /&gt;
			-- Normal case&lt;br /&gt;
			ii_start = ii_show-n_show_side&lt;br /&gt;
			ii_end = ii_show+n_show_side&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- For results column&lt;br /&gt;
	local new_res_ii = ii_start&lt;br /&gt;
	-- Pre-check for existence of column&lt;br /&gt;
	for ii = ii_start, ii_end do&lt;br /&gt;
		if Args[&amp;#039;result&amp;#039;..ii] then results_defined = true end&lt;br /&gt;
	end&lt;br /&gt;
	-- Remove results header if it is unused&lt;br /&gt;
	if full_table and not results_defined then&lt;br /&gt;
		-- First get it as one string, then use string replace to replace that header by empty string&lt;br /&gt;
		local t_str = tostring(table.concat(t))&lt;br /&gt;
		t_str = mw.ustring.gsub( t_str, results_header_txt, &amp;#039;&amp;#039; )&lt;br /&gt;
		N_cols = N_cols-1 -- There is actually one column less&lt;br /&gt;
		t = {}&lt;br /&gt;
		table.insert(t, t_str)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Write rows&lt;br /&gt;
	local team_name, team_code_ii, team_code_jj, pos_num, group_txt, note_local&lt;br /&gt;
	local note_string, note_local, note_local_num, note_id&lt;br /&gt;
	local note_id_list = {}&lt;br /&gt;
	local hth_id_list = {}&lt;br /&gt;
	for ii = ii_start, ii_end do&lt;br /&gt;
		-- First get code&lt;br /&gt;
		team_code_ii = team_list[ii]&lt;br /&gt;
		-- Now read values&lt;br /&gt;
		pos_num = Args[&amp;#039;pos_&amp;#039;..team_code_ii]			or ii&lt;br /&gt;
		group_txt = Args[&amp;#039;group_&amp;#039;..team_code_ii]		or &amp;#039; &amp;#039;&lt;br /&gt;
		team_name = Args[&amp;#039;name_&amp;#039;..team_code_ii]		 	or team_code_ii&lt;br /&gt;
		note_local = Args[&amp;#039;note_&amp;#039;..team_code_ii] 		or nil&lt;br /&gt;
		&lt;br /&gt;
		-- Does it need a promotion/qualification/relegation tag&lt;br /&gt;
		local result_local = Args[&amp;#039;result&amp;#039;..ii] or nil&lt;br /&gt;
		local bg_col = nil&lt;br /&gt;
		-- Get local background colour&lt;br /&gt;
		if result_local then&lt;br /&gt;
			bg_col = result_col[Args[&amp;#039;col_&amp;#039;..result_local]] or Args[&amp;#039;col_&amp;#039;..result_local] or &amp;#039;white&amp;#039;&lt;br /&gt;
			bg_col = &amp;#039;background-color:&amp;#039;..bg_col..&amp;#039;;&amp;#039; 	-- Full style tag&lt;br /&gt;
		end&lt;br /&gt;
		if not bg_col then bg_col = &amp;#039;background-color:transparent;&amp;#039; end -- Becomes default if undefined&lt;br /&gt;
		&lt;br /&gt;
		-- Bold this line or not&lt;br /&gt;
		local ii_fw = ii == ii_show and &amp;#039;font-weight: bold;&amp;#039; or &amp;#039;font-weight: normal;&amp;#039;&lt;br /&gt;
		&lt;br /&gt;
		-- Check whether there is a note or not, if so get text ready for it&lt;br /&gt;
		if note_local and full_table then&lt;br /&gt;
			-- Set global check for notes to true&lt;br /&gt;
			notes_exist = true&lt;br /&gt;
			-- There are now 3 options for notes&lt;br /&gt;
			-- 1) It is a full note&lt;br /&gt;
			-- 2) It is a referal to another note (i.e. it&amp;#039;s just a team code; e.g. note_AAA=Text, note_BBB=AAA) in which the note for BBB should link to the same footnote as AAA, with&lt;br /&gt;
			-- 2a) The other linked note exist in the part of the table shown&lt;br /&gt;
			-- 2b) The part of the note does not exist in the part of the table shown&lt;br /&gt;
			if not Args[&amp;#039;note_&amp;#039;..note_local] then&lt;br /&gt;
				-- Option 1&lt;br /&gt;
				-- Now define the identifier for this&lt;br /&gt;
				note_id = &amp;#039;&amp;quot;table_note_&amp;#039;..team_code_ii..rand_val..&amp;#039;&amp;quot;&amp;#039; -- Add random end for unique ID if more tables are present on article (which might otherwise share an ID)&lt;br /&gt;
				note_id_list[team_code_ii] = note_id&lt;br /&gt;
				&lt;br /&gt;
				-- Call refn template&lt;br /&gt;
				note_string = frame:expandTemplate{ title = &amp;#039;efn&amp;#039;, args = { group=&amp;#039;Table_notes&amp;#039;,  name=note_id, note_local} }&lt;br /&gt;
			else &lt;br /&gt;
				-- Option 2&lt;br /&gt;
				-- It is option 2a in either one if either the main note is inside the sub-table&lt;br /&gt;
				--                                  or another ref to that note is inside the sub-table&lt;br /&gt;
				-- Basically when it either has been defined, or the main link will be in the table&lt;br /&gt;
				note_local_num = team_list[note_local]&lt;br /&gt;
				if note_id_list[note_local] or ((note_local_num &amp;gt;= ii_start) and (note_local_num &amp;lt;= ii_end)) then&lt;br /&gt;
					-- Option 2a&lt;br /&gt;
					note_id = &amp;#039;&amp;quot;table_note_&amp;#039;..note_local..rand_val..&amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
					note_string = frame:extensionTag{ name = &amp;#039;ref&amp;#039;, args = { group = &amp;#039;lower-alpha&amp;#039;, name = note_id} }&lt;br /&gt;
				else&lt;br /&gt;
					-- Option 2b&lt;br /&gt;
					-- Now define the identifier for this&lt;br /&gt;
					note_id = &amp;#039;&amp;quot;table_note_&amp;#039;..note_local..rand_val..&amp;#039;&amp;quot;&amp;#039; -- Add random end for unique ID&lt;br /&gt;
					note_id_list[note_local] = note_id&lt;br /&gt;
					&lt;br /&gt;
					-- Call refn template&lt;br /&gt;
					note_string = frame:expandTemplate{ title = &amp;#039;efn&amp;#039;, args = { group=&amp;#039;Table_notes&amp;#039;,  name=note_id, Args[&amp;#039;note_&amp;#039;..note_local]} }&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			note_string = &amp;#039;&amp;#039;;&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- Insert status when needed&lt;br /&gt;
		local status_string = &amp;#039;&amp;#039;&lt;br /&gt;
		local status_local = Args[&amp;#039;status_&amp;#039;..team_code_ii]&lt;br /&gt;
		local status_let_first = true&lt;br /&gt;
		local curr_letter&lt;br /&gt;
		-- Only if it is defined&lt;br /&gt;
		if status_local then&lt;br /&gt;
			-- Take it letter by letter&lt;br /&gt;
			for jjj = 1,mw.ustring.len(status_local) do&lt;br /&gt;
				curr_letter = mw.ustring.upper(mw.ustring.sub(status_local,jjj,jjj))&lt;br /&gt;
				-- See whether it exist&lt;br /&gt;
				if t_status.code[curr_letter] then&lt;br /&gt;
					-- Depending on whether it is the first letter of not&lt;br /&gt;
					if status_let_first then&lt;br /&gt;
						status_string = curr_letter&lt;br /&gt;
						t_status.called[curr_letter] = true&lt;br /&gt;
						status_let_first = false&lt;br /&gt;
					else&lt;br /&gt;
						status_string = status_string..&amp;#039;, &amp;#039;..curr_letter&lt;br /&gt;
						t_status.called[curr_letter] = true&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
		end&lt;br /&gt;
		-- Only add brackets/dash and bolding if it exist&lt;br /&gt;
			if not status_let_first then &lt;br /&gt;
				if t_status.position == &amp;#039;before&amp;#039; then&lt;br /&gt;
					status_string = &amp;#039;&amp;lt;span style=&amp;quot;font-weight:bold&amp;quot;&amp;gt;&amp;#039;..string.lower(status_string)..&amp;#039; &amp;amp;ndash;&amp;lt;/span&amp;gt; &amp;#039; &lt;br /&gt;
				else&lt;br /&gt;
					status_string = &amp;#039; &amp;lt;span style=&amp;quot;font-weight:bold&amp;quot;&amp;gt;(&amp;#039;..status_string..&amp;#039;)&amp;lt;/span&amp;gt;&amp;#039; &lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- Now build the rows&lt;br /&gt;
		table.insert(t,&amp;#039;|- \n&amp;#039;)																			-- New row&lt;br /&gt;
		table.insert(t,&amp;#039;! scope=&amp;quot;row&amp;quot; style=&amp;quot;text-align: center;&amp;#039;..ii_fw..bg_col..&amp;#039;&amp;quot;| &amp;#039;..pos_num..&amp;#039;\n&amp;#039;)	-- Position number&lt;br /&gt;
		if full_table and group_col then&lt;br /&gt;
			table.insert(t,&amp;#039;| style=&amp;quot;&amp;#039;..ii_fw..bg_col..&amp;#039;&amp;quot; |&amp;#039;..group_txt..&amp;#039;\n&amp;#039;) 							-- Group number/name&lt;br /&gt;
		end&lt;br /&gt;
		-- Build the team string order based on status position&lt;br /&gt;
		local team_string&lt;br /&gt;
		if t_status.position == &amp;#039;before&amp;#039; then&lt;br /&gt;
			team_string = status_string..team_name..note_string&lt;br /&gt;
		else&lt;br /&gt;
			team_string = team_name..note_string..status_string&lt;br /&gt;
		end&lt;br /&gt;
		table.insert(t,&amp;#039;| style=&amp;quot;text-align: left; white-space:nowrap;&amp;#039;..ii_fw..bg_col..&amp;#039;&amp;quot;| &amp;#039;..team_string..&amp;#039;\n&amp;#039;)-- Team (with possible note)&lt;br /&gt;
		-- Call to subfunction&lt;br /&gt;
		t_return = p_style.row(frame,t,Args,p_sub,notes_exist,hth_id_list,full_table,rand_val,team_list,team_code_ii,ii_start,ii_end,ii_fw,bg_col,N_teams,ii,ii_show)&lt;br /&gt;
		t = t_return.t&lt;br /&gt;
		notes_exist = t_return.notes_exist&lt;br /&gt;
		hth_id_list = t_return.hth_id_list&lt;br /&gt;
		&lt;br /&gt;
		-- Now check what needs to be added inside the results column&lt;br /&gt;
		if full_table then&lt;br /&gt;
			local res_jjj&lt;br /&gt;
			if ii == new_res_ii then&lt;br /&gt;
				-- First check how many rows you need for this&lt;br /&gt;
				N_rows_res = 1&lt;br /&gt;
				jjj = ii+1&lt;br /&gt;
				result_local = Args[&amp;#039;result&amp;#039;..ii] or &amp;#039;&amp;#039;&lt;br /&gt;
				local cont_loop = true&lt;br /&gt;
				while (jjj&amp;lt;=ii_end) and cont_loop do&lt;br /&gt;
					if Args[&amp;#039;split&amp;#039;..tostring(jjj-1)] then&lt;br /&gt;
						cont_loop = false&lt;br /&gt;
						new_res_ii = jjj&lt;br /&gt;
					else&lt;br /&gt;
						res_jjj = Args[&amp;#039;result&amp;#039;..jjj] or &amp;#039;&amp;#039;&lt;br /&gt;
						if result_local == res_jjj then &lt;br /&gt;
							N_rows_res = N_rows_res+1 &lt;br /&gt;
						else&lt;br /&gt;
							cont_loop = false&lt;br /&gt;
							new_res_ii = jjj&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
					jjj = jjj+1&lt;br /&gt;
				end&lt;br /&gt;
				-- Now create this field (reuse ii_fw and bg_col)&lt;br /&gt;
				-- Bold (if in range) or not&lt;br /&gt;
				if ii_show and (ii_show&amp;gt;=ii) and (ii_show&amp;lt;=(ii+N_rows_res-1)) then&lt;br /&gt;
					ii_fw = &amp;#039;font-weight: bold;&amp;#039;&lt;br /&gt;
				else&lt;br /&gt;
					ii_fw = &amp;#039;font-weight: normal;&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
				-- Get background colour&lt;br /&gt;
				bg_col = nil&lt;br /&gt;
				if Args[&amp;#039;result&amp;#039;..ii] then&lt;br /&gt;
					bg_col = result_col[Args[&amp;#039;col_&amp;#039;..result_local]] or Args[&amp;#039;col_&amp;#039;..result_local] or &amp;#039;white&amp;#039;&lt;br /&gt;
					bg_col = &amp;#039;background-color:&amp;#039;..bg_col..&amp;#039;;&amp;#039; 	-- Full style tag&lt;br /&gt;
				end&lt;br /&gt;
				if not bg_col then bg_col = &amp;#039;background-color:transparent;&amp;#039; end -- Becomes default if undefined&lt;br /&gt;
				-- Check for notes&lt;br /&gt;
				local note_res_string, note_ref, note_text&lt;br /&gt;
				if Args[&amp;#039;note_res_&amp;#039;..result_local] then&lt;br /&gt;
					notes_exist = true&lt;br /&gt;
					local note_res_local = Args[&amp;#039;note_res_&amp;#039;..result_local]&lt;br /&gt;
					if not Args[&amp;#039;note_res_&amp;#039;..note_res_local] then&lt;br /&gt;
						-- It does not point to another result note&lt;br /&gt;
						note_ref = &amp;#039;res_&amp;#039;..result_local&lt;br /&gt;
						note_id = &amp;#039;&amp;quot;table_note_res_&amp;#039;..result_local..rand_val..&amp;#039;&amp;quot;&amp;#039; -- Identifier&lt;br /&gt;
						note_text = note_res_local&lt;br /&gt;
					else&lt;br /&gt;
						-- It does point to another result note&lt;br /&gt;
						note_ref = &amp;#039;res_&amp;#039;..note_res_local&lt;br /&gt;
						note_id = &amp;#039;&amp;quot;table_note_res_&amp;#039;..note_res_local..rand_val..&amp;#039;&amp;quot;&amp;#039; -- Identifier&lt;br /&gt;
						note_text = Args[&amp;#039;note_res_&amp;#039;..note_res_local]&lt;br /&gt;
					end&lt;br /&gt;
					-- Check whether it is already printed&lt;br /&gt;
					if not note_id_list[note_ref] then&lt;br /&gt;
						-- Print it&lt;br /&gt;
						note_id_list[note_ref] = note_id&lt;br /&gt;
						note_res_string = frame:expandTemplate{ title = &amp;#039;efn&amp;#039;, args = { group=&amp;#039;Table_notes&amp;#039;,  name=note_id, note_text} }&lt;br /&gt;
					else&lt;br /&gt;
						-- Refer to it&lt;br /&gt;
						note_res_string = frame:extensionTag{ name = &amp;#039;ref&amp;#039;, args = { group = &amp;#039;lower-alpha&amp;#039;, name = note_id} }&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					note_res_string = &amp;#039;&amp;#039;&lt;br /&gt;
				end&lt;br /&gt;
				-- Get text&lt;br /&gt;
				local text_result = Args[&amp;#039;text_&amp;#039;..result_local] or &amp;#039;&amp;#039;&lt;br /&gt;
				text_field_result = &amp;#039;| style=&amp;quot;&amp;#039;..ii_fw..bg_col..&amp;#039;&amp;quot; rowspan=&amp;quot;&amp;#039;..tostring(N_rows_res)..&amp;#039;&amp;quot; |&amp;#039;..text_result..note_res_string..&amp;#039;\n&amp;#039;&lt;br /&gt;
				-- See whether it is needed (only when blank for all entries)&lt;br /&gt;
				if results_defined then table.insert(t,text_field_result) end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
		-- Insert match row if needed&lt;br /&gt;
		if match_table then&lt;br /&gt;
			-- Add empty cell&lt;br /&gt;
			table.insert(t,&amp;#039;| style=&amp;quot;background-color:white;border-top:white;border-bottom:white;&amp;quot;| \n&amp;#039;)&lt;br /&gt;
			&lt;br /&gt;
			-- Now include note to match results if needed &lt;br /&gt;
			for jj=top_pos,N_teams do&lt;br /&gt;
				team_code_jj = team_list[jj]&lt;br /&gt;
				if ii == jj then&lt;br /&gt;
					-- Nothing&lt;br /&gt;
				else&lt;br /&gt;
					local match_note = Args[&amp;#039;match_&amp;#039;..team_code_ii..&amp;#039;_&amp;#039;..team_code_jj..&amp;#039;_note&amp;#039;]&lt;br /&gt;
					if match_note then&lt;br /&gt;
						notes_exist = true&lt;br /&gt;
						-- Only when it exist&lt;br /&gt;
						-- First check for existence of reference for note&lt;br /&gt;
						if not Args[&amp;#039;note_&amp;#039;..match_note] then&lt;br /&gt;
							-- It&amp;#039;s the entry&lt;br /&gt;
							note_string = frame:expandTemplate{ title = &amp;#039;efn&amp;#039;, args = { group=&amp;#039;Table_notes&amp;#039;,  match_note} }&lt;br /&gt;
						else &lt;br /&gt;
							-- Check for existence elsewhere&lt;br /&gt;
							note_local_num = team_list[match_note]&lt;br /&gt;
							if note_id_list[match_note] or ((note_local_num &amp;gt;= ii_start) and (note_local_num &amp;lt;= ii_end)) then&lt;br /&gt;
								-- It exists&lt;br /&gt;
								note_id = &amp;#039;&amp;quot;table_note_&amp;#039;..match_note..rand_val..&amp;#039;&amp;quot;&amp;#039; -- Identifier&lt;br /&gt;
								note_string = frame:extensionTag{ name = &amp;#039;ref&amp;#039;, args = { group = &amp;#039;lower-alpha&amp;#039;, name = note_id} }&lt;br /&gt;
							else&lt;br /&gt;
								-- Now define the identifier for this&lt;br /&gt;
								note_id = &amp;#039;&amp;quot;table_note_&amp;#039;..match_note..rand_val..&amp;#039;&amp;quot;&amp;#039; -- Add random end for unique ID&lt;br /&gt;
								note_id_list[match_note] = note_id&lt;br /&gt;
								-- Call refn template&lt;br /&gt;
								note_string = frame:expandTemplate{ title = &amp;#039;efn&amp;#039;, args = { group=&amp;#039;Table_notes&amp;#039;, name=note_id, Args[&amp;#039;note_&amp;#039;..match_note]} }&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
&lt;br /&gt;
						-- Now append this to the match result string&lt;br /&gt;
						Args[&amp;#039;match_&amp;#039;..team_code_ii..&amp;#039;_&amp;#039;..team_code_jj] = Args[&amp;#039;match_&amp;#039;..team_code_ii..&amp;#039;_&amp;#039;..team_code_jj]..note_string&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- Add rest of match row&lt;br /&gt;
			t = p_matches.row(t,Args,N_teams,team_list,ii,ii_show)&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
		-- Now, if needed, insert a split (solid line to indicate split in standings, but only when it is not at the last shown position)&lt;br /&gt;
		if Args[&amp;#039;split&amp;#039;..ii] and (ii&amp;lt;ii_end) then&lt;br /&gt;
			-- Base size on N_cols (it needs 2*N_cols |)&lt;br /&gt;
			table.insert(t,&amp;#039;|- style=&amp;quot;background-color:&amp;#039;..result_col[&amp;#039;black1&amp;#039;]..&amp;#039;; line-height:3pt;&amp;quot;\n&amp;#039;)&lt;br /&gt;
			table.insert(t,string.rep(&amp;#039;|&amp;#039;,2*N_cols)..&amp;#039;\n&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Close table&lt;br /&gt;
	table.insert(t, &amp;#039;|}\n&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	-- Get info for footer&lt;br /&gt;
	local update = Args[&amp;#039;update&amp;#039;]			or &amp;#039;unknown&amp;#039;&lt;br /&gt;
	local start_date = Args[&amp;#039;start_date&amp;#039;] 	or &amp;#039;unknown&amp;#039;&lt;br /&gt;
	local source = Args[&amp;#039;source&amp;#039;]			or frame:expandTemplate{ title = &amp;#039;citation needed&amp;#039;, args = { reason=&amp;#039;No source parameter defined&amp;#039;, date=os.date(&amp;#039;%B %Y&amp;#039;) } }&lt;br /&gt;
	local class_rules = Args[&amp;#039;class_rules&amp;#039;]	or nil&lt;br /&gt;
	&lt;br /&gt;
	-- Create footer text&lt;br /&gt;
	-- Date updating&lt;br /&gt;
	local matches_text = Args[&amp;#039;matches_text&amp;#039;] or &amp;#039;match(es)&amp;#039;&lt;br /&gt;
	if string.lower(update)==&amp;#039;complete&amp;#039; then&lt;br /&gt;
		-- Do nothing&lt;br /&gt;
	elseif update==&amp;#039;&amp;#039; then&lt;br /&gt;
		-- Empty parameter&lt;br /&gt;
		table.insert(t_footer,&amp;#039;Updated to &amp;#039;..matches_text..&amp;#039; played on unknown. &amp;#039;)&lt;br /&gt;
	elseif string.lower(update)==&amp;#039;future&amp;#039; then&lt;br /&gt;
		-- Future start date&lt;br /&gt;
		table.insert(t_footer,&amp;#039;First &amp;#039;..matches_text..&amp;#039; will be played on &amp;#039;..start_date..&amp;#039;. &amp;#039;)&lt;br /&gt;
	else&lt;br /&gt;
		table.insert(t_footer,&amp;#039;Updated to &amp;#039;..matches_text..&amp;#039; played on &amp;#039;..update..&amp;#039;. &amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Stack footer or not&lt;br /&gt;
	local stack_footer_val = firstnonblank(Pargs[&amp;#039;stack_footer&amp;#039;], Args[&amp;#039;stack_footer&amp;#039;]) or &amp;#039;no&amp;#039;&lt;br /&gt;
	local footer_break = false&lt;br /&gt;
	if yesno(stack_footer_val) then footer_break = true end&lt;br /&gt;
	&lt;br /&gt;
	-- Variable for linebreak&lt;br /&gt;
	local stack_string = &amp;#039;&amp;lt;br&amp;gt;&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	if footer_break and (not (string.lower(update)==&amp;#039;complete&amp;#039;)) then table.insert(t_footer,stack_string) end&lt;br /&gt;
	&lt;br /&gt;
	table.insert(t_footer,&amp;#039;Source: &amp;#039;..source)&lt;br /&gt;
	if class_rules and full_table and (not hide_class_rules) then&lt;br /&gt;
		table.insert(t_footer,&amp;#039;&amp;lt;br&amp;gt;Rules for classification: &amp;#039;..class_rules)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Now for the named status&lt;br /&gt;
	local status_exist = false&lt;br /&gt;
	local status_string = &amp;#039;&amp;#039;&lt;br /&gt;
	local curr_letter&lt;br /&gt;
	for jjj = 1,mw.ustring.len(t_status.letters) do&lt;br /&gt;
		curr_letter = mw.ustring.upper(mw.ustring.sub(t_status.letters,jjj,jjj))&lt;br /&gt;
		if t_status.called[curr_letter] then&lt;br /&gt;
			if (footer_break and status_exist) then&lt;br /&gt;
				status_string = status_string..stack_string&lt;br /&gt;
			end&lt;br /&gt;
			if t_status.position == &amp;#039;before&amp;#039; then&lt;br /&gt;
				status_string = status_string..&amp;#039;&amp;lt;span style=&amp;quot;font-weight:bold&amp;quot;&amp;gt;&amp;#039;..string.lower(curr_letter)..&amp;#039; &amp;amp;ndash;&amp;lt;/span&amp;gt; &amp;#039;..t_status.code[curr_letter]..&amp;#039;; &amp;#039;&lt;br /&gt;
			else&lt;br /&gt;
				status_string = status_string..&amp;#039;&amp;lt;span style=&amp;quot;font-weight:bold&amp;quot;&amp;gt;(&amp;#039;..curr_letter..&amp;#039;)&amp;lt;/span&amp;gt; &amp;#039;..t_status.code[curr_letter]..&amp;#039;; &amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			status_exist = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Now end it with a point instead (if it contains entries the &amp;#039;; &amp;#039; needs to be removed)&lt;br /&gt;
	if status_exist then&lt;br /&gt;
		status_string = &amp;#039;&amp;lt;br&amp;gt;&amp;#039;..mw.ustring.sub(status_string,1,mw.ustring.len(status_string)-2)..&amp;#039;.&amp;#039;&lt;br /&gt;
		table.insert(t_footer,status_string)&lt;br /&gt;
	end&lt;br /&gt;
	-- Add notes (if applicable)&lt;br /&gt;
	if notes_exist then&lt;br /&gt;
		table.insert(t_footer,&amp;#039;&amp;lt;br&amp;gt;Notes:&amp;#039;)&lt;br /&gt;
		-- As reflist size text&lt;br /&gt;
		t_footer = &amp;#039;&amp;lt;div class=&amp;quot;reflist&amp;quot;&amp;gt;&amp;#039;..table.concat(t_footer)..&amp;#039;&amp;lt;/div&amp;gt;&amp;#039;&lt;br /&gt;
		t_footer = t_footer..frame:expandTemplate{ title = &amp;#039;notelist&amp;#039;, args = { group=&amp;#039;Table_notes&amp;#039;} }&lt;br /&gt;
	else&lt;br /&gt;
		-- As reflist size text&lt;br /&gt;
		t_footer = &amp;#039;&amp;lt;div class=&amp;quot;reflist&amp;quot;&amp;gt;&amp;#039;..table.concat(t_footer)..&amp;#039;&amp;lt;/div&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	-- Add footer to main text table&lt;br /&gt;
	table.insert(t,t_footer)&lt;br /&gt;
	&lt;br /&gt;
	return table.concat(t)&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>TheMooCows</name></author>
	</entry>
</feed>