<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thegoonshow.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACollege_color</id>
	<title>Module:College color - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.thegoonshow.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3ACollege_color"/>
	<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:College_color&amp;action=history"/>
	<updated>2026-05-13T23:33:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://www.thegoonshow.co.uk/wiki/index.php?title=Module:College_color&amp;diff=10935&amp;oldid=prev</id>
		<title>Kurt: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:College_color&amp;diff=10935&amp;oldid=prev"/>
		<updated>2022-07-30T21:46:51Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:46, 30 July 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&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>Kurt</name></author>
	</entry>
	<entry>
		<id>https://www.thegoonshow.co.uk/wiki/index.php?title=Module:College_color&amp;diff=10934&amp;oldid=prev</id>
		<title>en&gt;Frietjes: optional color=auto</title>
		<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:College_color&amp;diff=10934&amp;oldid=prev"/>
		<updated>2021-09-20T16:00:56Z</updated>

		<summary type="html">&lt;p&gt;optional color=auto&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 {{CollegePrimaryHex}}, {{CollegePrimaryStyle}},&lt;br /&gt;
-- {{CollegePrimaryColorLink}}, {{CollegeSecondaryHex}},&lt;br /&gt;
-- {{CollegeSecondaryStyle}}, {{CollegeSecondaryColorLink}}, and {{NCAA color}}&lt;br /&gt;
--&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local data_module = &amp;quot;Module:College color/data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local function stripwhitespace(text)&lt;br /&gt;
	return text:match(&amp;quot;^%s*(.-)%s*$&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
local function ucfirst(s)&lt;br /&gt;
	local first = s:sub(1, 1)&lt;br /&gt;
	local others = s:sub(2, -1)&lt;br /&gt;
	return first:upper() .. others&lt;br /&gt;
end&lt;br /&gt;
local function bordercss(c, w)&lt;br /&gt;
	local s = 'inset ' .. w .. 'px ' .. w .. 'px 0 ' .. c &lt;br /&gt;
		.. ', inset -' .. w .. 'px -' .. w .. 'px 0 ' .. c&lt;br /&gt;
	return 'box-shadow: ' .. s .. ';'&lt;br /&gt;
end&lt;br /&gt;
local function sRGB ( v )&lt;br /&gt;
	if (v &amp;lt;= 0.03928) then&lt;br /&gt;
		v = v / 12.92&lt;br /&gt;
	else&lt;br /&gt;
		v = math.pow((v+0.055)/1.055, 2.4)&lt;br /&gt;
	end&lt;br /&gt;
	return v&lt;br /&gt;
end&lt;br /&gt;
local function color2lum( origc )&lt;br /&gt;
	local c = stripwhitespace(origc or ''):lower()&lt;br /&gt;
&lt;br /&gt;
	-- remove leading # (if there is one)&lt;br /&gt;
	c = mw.ustring.match(c, '^[#]*([a-f0-9]*)$')&lt;br /&gt;
&lt;br /&gt;
	-- split into rgb&lt;br /&gt;
	local cs = mw.text.split(c or '', '')&lt;br /&gt;
	if( #cs == 6 ) then&lt;br /&gt;
		local R = sRGB( (16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[2]))/255 )&lt;br /&gt;
		local G = sRGB( (16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[4]))/255 )&lt;br /&gt;
		local B = sRGB( (16*tonumber('0x' .. cs[5]) + tonumber('0x' .. cs[6]))/255 )&lt;br /&gt;
&lt;br /&gt;
		return 0.2126 * R + 0.7152 * G + 0.0722 * B&lt;br /&gt;
	elseif ( #cs == 3 ) then&lt;br /&gt;
		local R = sRGB( (16*tonumber('0x' .. cs[1]) + tonumber('0x' .. cs[1]))/255 )&lt;br /&gt;
		local G = sRGB( (16*tonumber('0x' .. cs[2]) + tonumber('0x' .. cs[2]))/255 )&lt;br /&gt;
		local B = sRGB( (16*tonumber('0x' .. cs[3]) + tonumber('0x' .. cs[3]))/255 )&lt;br /&gt;
&lt;br /&gt;
		return 0.2126 * R + 0.7152 * G + 0.0722 * B&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- failure&lt;br /&gt;
	error('Invalid hex color ' .. origc, 2)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function remove_sport(team)&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot;%s*&amp;lt;[Bb][Rr][^&amp;lt;&amp;gt;]*&amp;gt;%s*&amp;quot;, ' ');&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Tt]eam$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Bb]asketball$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Bb]aseball$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Cc]ross [Cc]ountry$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ff]ield [Hh]ockey$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ff]ootball$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Gg]olf$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Gg]ymnastics$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ii]ce [Hh]ockey$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ll]acrosse$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Rr]owing$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ss]ki$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ss]occer$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ss]oftball$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ss]wim$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Tt]ennis$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Tt]rack [Aa]nd [Ff]ield$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Vv]olleyball$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ww]restling$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Ww]omen's$&amp;quot;, '')&lt;br /&gt;
	team = mw.ustring.gsub(team, &amp;quot; [Mm]en's$&amp;quot;, '')&lt;br /&gt;
&lt;br /&gt;
	return team&lt;br /&gt;
end&lt;br /&gt;
local function get_colors(team, unknown)&lt;br /&gt;
	team = stripwhitespace(team or '')&lt;br /&gt;
	unknown = unknown or {&amp;quot;DCDCDC&amp;quot;, &amp;quot;000000&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
	local use_default = {&lt;br /&gt;
		[&amp;quot;&amp;quot;] = 1,&lt;br /&gt;
		[&amp;quot;retired&amp;quot;] = 1,&lt;br /&gt;
		[&amp;quot;free agent&amp;quot;] = 1,&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	local colors = nil&lt;br /&gt;
&lt;br /&gt;
	if ( team and use_default[team:lower()] ) then&lt;br /&gt;
		colors = {&amp;quot;DCDCDC&amp;quot;, &amp;quot;000000&amp;quot;}&lt;br /&gt;
	else&lt;br /&gt;
		local all_colors = mw.loadData(data_module)&lt;br /&gt;
		colors = all_colors[team]&lt;br /&gt;
		if ( colors and type(colors) == 'string' ) then&lt;br /&gt;
			colors = all_colors[colors]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return colors or unknown&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_color(team, num, num2)&lt;br /&gt;
	local colors = get_colors(team, nil)&lt;br /&gt;
&lt;br /&gt;
	num = tonumber(num:match('[1-3]') or '0')&lt;br /&gt;
	num2 = tonumber(num2:match('[1-3]') or '0')&lt;br /&gt;
	if ( num ) then&lt;br /&gt;
		return colors[num] or colors[num2] or ''&lt;br /&gt;
	else&lt;br /&gt;
		return ''&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_style1(team, borderwidth, fontcolor)&lt;br /&gt;
	local colors = get_colors(team, nil)&lt;br /&gt;
&lt;br /&gt;
	local color = '#' .. (colors[3] or colors[2] or '')&lt;br /&gt;
	if fontcolor and fontcolor == 'auto' then&lt;br /&gt;
		-- compute the luminosity of the background&lt;br /&gt;
		local lum = color2lum(colors[1] or '')&lt;br /&gt;
		-- compute the contrast with white and black&lt;br /&gt;
		local wcontrast = (1 + 0.05)/(lum + 0.05)&lt;br /&gt;
		local bcontrast = (lum + 0.05)/(0 + 0.05)&lt;br /&gt;
		-- select the text color with the best contrast&lt;br /&gt;
		if( bcontrast &amp;gt; wcontrast + 1.25 ) then&lt;br /&gt;
			fontcolor = '#000000'&lt;br /&gt;
		else&lt;br /&gt;
			fontcolor = '#FFFFFF'&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local style = 'background-color:#' .. (colors[1] or '') .. ';color:' .. (fontcolor or color) .. ';'&lt;br /&gt;
	-- remove the border if it's nearly white&lt;br /&gt;
	if ((1 + 0.05)/(color2lum(color) + 0.05) &amp;lt; 1.25) then&lt;br /&gt;
		borderwidth = '0'&lt;br /&gt;
	end&lt;br /&gt;
	borderwidth = tonumber(borderwidth or '2') or 0&lt;br /&gt;
	if (borderwidth &amp;gt; 0 and color ~= '#FFFFFF') then&lt;br /&gt;
		style = style .. bordercss(color, borderwidth)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return style&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_style2(team, borderwidth, fontcolor)&lt;br /&gt;
	local colors = get_colors(team, nil)&lt;br /&gt;
&lt;br /&gt;
	local color = '#' .. (colors[1] or '')&lt;br /&gt;
	if fontcolor and fontcolor == 'auto' then&lt;br /&gt;
		-- compute the luminosity of the background&lt;br /&gt;
		local lum = color2lum(colors[3] or colors[2] or '')&lt;br /&gt;
		-- compute the contrast with white and black&lt;br /&gt;
		local wcontrast = (1 + 0.05)/(lum + 0.05)&lt;br /&gt;
		local bcontrast = (lum + 0.05)/(0 + 0.05)&lt;br /&gt;
		-- select the text color with the best contrast&lt;br /&gt;
		if( bcontrast &amp;gt; wcontrast + 1.25 ) then&lt;br /&gt;
			fontcolor = '#000000'&lt;br /&gt;
		else&lt;br /&gt;
			fontcolor = '#FFFFFF'&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local style = 'background-color:#' .. (colors[3] or colors[2] or '') .. ';color:' .. (fontcolor or color) .. ';'&lt;br /&gt;
	-- remove the border if it's nearly white&lt;br /&gt;
	if ((1 + 0.05)/(color2lum(color) + 0.05) &amp;lt; 1.25) then&lt;br /&gt;
		borderwidth = '0'&lt;br /&gt;
	end&lt;br /&gt;
	borderwidth = tonumber(borderwidth or '2') or 0&lt;br /&gt;
	if (borderwidth &amp;gt; 0 and color ~= '#FFFFFF') then&lt;br /&gt;
		style = style .. bordercss(color, borderwidth)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return style&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_header1(team, borderwidth)&lt;br /&gt;
	local colors = get_colors(team, nil)&lt;br /&gt;
	-- set the default background&lt;br /&gt;
	local background = (colors[1] or 'FFFFFF'):upper()&lt;br /&gt;
	-- set background to white if it's nearly white&lt;br /&gt;
	if ((1 + 0.05)/(color2lum(background) + 0.05) &amp;lt; 1.25) then&lt;br /&gt;
		background = 'FFFFFF'&lt;br /&gt;
	end&lt;br /&gt;
	-- now pick a font color&lt;br /&gt;
	local fontcolor = '000000'&lt;br /&gt;
	-- compute the luminosity of the background&lt;br /&gt;
	local lum = color2lum(background)&lt;br /&gt;
	-- compute the contrast with white and black&lt;br /&gt;
	local wcontrast = (1 + 0.05)/(lum + 0.05)&lt;br /&gt;
	local bcontrast = (lum + 0.05)/(0 + 0.05)&lt;br /&gt;
	-- select the text color with the best contrast&lt;br /&gt;
	if( bcontrast &amp;gt; wcontrast + 1.25 ) then&lt;br /&gt;
		fontcolor = '000000'&lt;br /&gt;
	else&lt;br /&gt;
		fontcolor = 'FFFFFF'&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local style&lt;br /&gt;
	if( background == 'FFFFFF' ) then&lt;br /&gt;
		style = 'background-color:none;color:#' .. fontcolor .. ';'&lt;br /&gt;
	else&lt;br /&gt;
		style = 'background-color:#' .. background .. ';color:#' .. fontcolor .. ';'&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if borderwidth then&lt;br /&gt;
		borderwidth = tonumber(borderwidth or '2') or 0&lt;br /&gt;
		local bordercolor = (colors[3] or colors[2] or 'FFFFFF'):upper()&lt;br /&gt;
		if (borderwidth &amp;gt; 0 and bordercolor ~= 'FFFFFF') then&lt;br /&gt;
			-- do not add a border if it's nearly white&lt;br /&gt;
			if ((1 + 0.05)/(color2lum(bordercolor) + 0.05) &amp;gt;= 1.25) then&lt;br /&gt;
				style = style .. bordercss('#' .. bordercolor, borderwidth)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return style&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_header2(team)&lt;br /&gt;
	local colors = get_colors(team, nil)&lt;br /&gt;
	-- set the default background&lt;br /&gt;
	local background = (colors[3] or colors[2] or 'FFFFFF'):upper()&lt;br /&gt;
	-- set background to white if it's nearly white&lt;br /&gt;
	if ((1 + 0.05)/(color2lum(background) + 0.05) &amp;lt; 1.25) then&lt;br /&gt;
		background = 'FFFFFF'&lt;br /&gt;
	end&lt;br /&gt;
	-- if the background is white, then use the primary background instead&lt;br /&gt;
	if( background == 'FFFFFF' ) then&lt;br /&gt;
		background = (colors[1] or 'FFFFFF'):upper()&lt;br /&gt;
	end&lt;br /&gt;
	-- now pick a font color&lt;br /&gt;
	local fontcolor = '000000'&lt;br /&gt;
	-- compute the luminosity of the background&lt;br /&gt;
	local lum = color2lum(background)&lt;br /&gt;
	-- compute the contrast with white and black&lt;br /&gt;
	local wcontrast = (1 + 0.05)/(lum + 0.05)&lt;br /&gt;
	local bcontrast = (lum + 0.05)/(0 + 0.05)&lt;br /&gt;
	-- select the text color with the best contrast&lt;br /&gt;
	if( bcontrast &amp;gt; wcontrast + 1.25 ) then&lt;br /&gt;
		fontcolor = '000000'&lt;br /&gt;
	else&lt;br /&gt;
		fontcolor = 'FFFFFF'&lt;br /&gt;
	end&lt;br /&gt;
	if( background == 'FFFFFF' ) then&lt;br /&gt;
		return 'background-color:none;color:#' .. fontcolor .. ';'&lt;br /&gt;
	else&lt;br /&gt;
		return 'background-color:#' .. background .. ';color:#' .. fontcolor .. ';'&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_table_head(args, team, ctype)&lt;br /&gt;
	local colors = get_colors(team, nil)&lt;br /&gt;
	local borderwidth = tonumber(args['border']) or 0&lt;br /&gt;
	-- set the default background&lt;br /&gt;
	local background = (ctype == 'p') and&lt;br /&gt;
		(colors[1] or 'FFFFFF'):upper() or&lt;br /&gt;
		(colors[3] or colors[2] or 'FFFFFF'):upper()&lt;br /&gt;
	-- now pick a font color&lt;br /&gt;
	local fontcolor = ''&lt;br /&gt;
	-- compute the luminosity of the background&lt;br /&gt;
	local lum = color2lum(background)&lt;br /&gt;
	-- compute the contrast with white and black&lt;br /&gt;
	local wcontrast = (1 + 0.05)/(lum + 0.05)&lt;br /&gt;
	local bcontrast = (lum + 0.05)/(0 + 0.05)&lt;br /&gt;
	-- select the text color with the best contrast&lt;br /&gt;
	if( bcontrast &amp;gt; wcontrast + 1.25 ) then&lt;br /&gt;
		fontcolor = '#000000'&lt;br /&gt;
	else&lt;br /&gt;
		fontcolor = '#FFFFFF'&lt;br /&gt;
	end&lt;br /&gt;
	local s = 'background-color:#' .. background .. ';color:' .. (args['color'] or fontcolor) .. ';'&lt;br /&gt;
	if borderwidth &amp;gt; 0 then&lt;br /&gt;
		local bc = (ctype == 'p') and &lt;br /&gt;
		(colors[3] or colors[2] or '') or (colors[1] or '')&lt;br /&gt;
		if bc ~= 'FFFFFF' then&lt;br /&gt;
			s = s .. bordercss('#' .. bc, borderwidth)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local res = '|-\n'&lt;br /&gt;
	for i=1,50 do&lt;br /&gt;
		if( args[i] ~= nil ) then&lt;br /&gt;
			local cstyle = 'scope=&amp;quot;col&amp;quot; style=&amp;quot;' .. s .. '&amp;quot;'&lt;br /&gt;
			if args['col' .. i .. 'span'] ~= nil then&lt;br /&gt;
				cstyle = cstyle .. ' colspan=' .. args['col' .. i .. 'span']&lt;br /&gt;
			end&lt;br /&gt;
			if args['class' .. i ] ~= nil then&lt;br /&gt;
				cstyle = cstyle .. ' class=&amp;quot;' .. args['class' .. i] .. '&amp;quot;'&lt;br /&gt;
			end&lt;br /&gt;
			res = res .. '! ' .. cstyle .. ' |' .. args[i] .. '\n'&lt;br /&gt;
		else&lt;br /&gt;
			return res .. '|-\n'&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return res .. '&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error!&amp;lt;/span&amp;gt;\n|-\n'&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_stripe1(team, borderwidth)&lt;br /&gt;
	local colors = get_colors(team, nil)&lt;br /&gt;
&lt;br /&gt;
	-- set the default scheme&lt;br /&gt;
	local background = colors[1] or ''&lt;br /&gt;
	local fontcolor = colors[2] or ''&lt;br /&gt;
	local bordercolor = (colors[3] or colors[2] or ''):upper()&lt;br /&gt;
	borderwidth = tonumber(borderwidth or '3') or 0&lt;br /&gt;
&lt;br /&gt;
	-- if there is no tertiary color, then pick a font color&lt;br /&gt;
	if (colors[3] == nil) then&lt;br /&gt;
		-- compute the luminosity of the background&lt;br /&gt;
		local lum = color2lum(colors[1])&lt;br /&gt;
		-- compute the contrast with white and black&lt;br /&gt;
		local wcontrast = (1 + 0.05)/(lum + 0.05)&lt;br /&gt;
		local bcontrast = (lum + 0.05)/(0 + 0.05)&lt;br /&gt;
		-- select the text color with the best contrast&lt;br /&gt;
		if( bcontrast &amp;gt; wcontrast + 1.25 ) then&lt;br /&gt;
			fontcolor = '000000'&lt;br /&gt;
		else&lt;br /&gt;
			fontcolor = 'FFFFFF'&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- finally build the style string&lt;br /&gt;
	local style = ''&lt;br /&gt;
	if (borderwidth &amp;gt; 0) then&lt;br /&gt;
		-- use the primary as the border if the border is white or close to white&lt;br /&gt;
		local bordercontrast = (1 + 0.05)/(color2lum(bordercolor) + 0.05)&lt;br /&gt;
		if (bordercontrast &amp;lt; 1.25) then&lt;br /&gt;
			bordercolor = background&lt;br /&gt;
			local fontcontrast = (1 + 0.05)/(color2lum(colors[2] or 'FFFFFF') + 0.05)&lt;br /&gt;
			if (fontcontrast &amp;lt; 1.25) then&lt;br /&gt;
				fontcolor = colors[2] or 'FFFFFF'&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		style = style .. ' border:' .. borderwidth .. 'px solid #' .. bordercolor .. ';'&lt;br /&gt;
		style = style .. ' border-left: none; border-right: none;'&lt;br /&gt;
		style = style .. ' box-shadow: inset 0 2px 0 #FEFEFE, inset 0 -2px 0 #FEFEFE;'&lt;br /&gt;
	end&lt;br /&gt;
	style = 'background-color:#' .. background .. ';color:#' .. fontcolor .. ';' .. style&lt;br /&gt;
&lt;br /&gt;
	return style&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_boxes(frame, team, order, sep)&lt;br /&gt;
	local function colorbox( h )&lt;br /&gt;
		local r = mw.html.create('')&lt;br /&gt;
		r:tag('span')&lt;br /&gt;
			:addClass('legend-color')&lt;br /&gt;
			:css('background-color', '#' .. (h or ''))&lt;br /&gt;
			:wikitext('&amp;amp;nbsp;')&lt;br /&gt;
		return tostring(r)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local colors = get_colors(team, 'unknown')&lt;br /&gt;
&lt;br /&gt;
	if type(colors) ~= 'table' then&lt;br /&gt;
		return ''&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local colorboxes = {}&lt;br /&gt;
	local colororder = {'1','2','3','4','5'}&lt;br /&gt;
	local namecheck = 0&lt;br /&gt;
	if order == '' then&lt;br /&gt;
		order = colors['order'] or ''&lt;br /&gt;
		namecheck = 1&lt;br /&gt;
	end&lt;br /&gt;
	if order ~= '' then&lt;br /&gt;
		colororder = mw.text.split(order, '')&lt;br /&gt;
	end&lt;br /&gt;
	for k,v in pairs(colororder) do&lt;br /&gt;
		local i = tonumber(v) or 0&lt;br /&gt;
		if(	namecheck == 0 or colors['name' .. i]) then&lt;br /&gt;
			if colors[i] then&lt;br /&gt;
				table.insert(colorboxes,colorbox(colors[i]))&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (#colorboxes &amp;gt; 0) then&lt;br /&gt;
		return frame:extensionTag{ name = 'templatestyles', args = { src = 'Legend/styles.css'} } .. table.concat(colorboxes, sep)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return ''&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_list(frame, team, num1, num2, num3, num4, num5, sep)&lt;br /&gt;
	local function colorbox( h )&lt;br /&gt;
		local r = mw.html.create('')&lt;br /&gt;
		r:tag('span')&lt;br /&gt;
			:addClass('legend-color')&lt;br /&gt;
			:css('background-color', '#' .. (h or ''))&lt;br /&gt;
			:wikitext('&amp;amp;nbsp;')&lt;br /&gt;
		return tostring(r)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local colors = get_colors(team, 'unknown')&lt;br /&gt;
&lt;br /&gt;
	if type(colors) ~= 'table' then&lt;br /&gt;
		return ''&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local nums = {&lt;br /&gt;
		tonumber(num1:match('[1-5]') or '0') or 0,&lt;br /&gt;
		tonumber(num2:match('[1-5]') or '0') or 0,&lt;br /&gt;
		tonumber(num3:match('[1-5]') or '0') or 0,&lt;br /&gt;
		tonumber(num4:match('[1-5]') or '0') or 0,&lt;br /&gt;
		tonumber(num5:match('[1-5]') or '0') or 0}&lt;br /&gt;
&lt;br /&gt;
	local colorboxes = {}&lt;br /&gt;
	local colornames = {}&lt;br /&gt;
	local colororder = {'1','2','3','4','5'}&lt;br /&gt;
	local order = colors['order'] or ''&lt;br /&gt;
	if(order ~= '') then&lt;br /&gt;
		colororder = mw.text.split(order, '')&lt;br /&gt;
	end&lt;br /&gt;
	for k,v in pairs(colororder) do&lt;br /&gt;
		local i = tonumber(v) or 0&lt;br /&gt;
		if ( nums[i] &amp;gt; 0 ) then&lt;br /&gt;
			if(	colors['name' .. nums[i]]) then&lt;br /&gt;
				table.insert(colornames,colors['name' .. nums[i]])&lt;br /&gt;
				table.insert(colorboxes,colorbox(colors[nums[i]] or ''))&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local res = ''&lt;br /&gt;
	if (#colornames &amp;gt; 0) then&lt;br /&gt;
		colornames[1] = ucfirst(colornames[1])&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	res = mw.text.listToText(&lt;br /&gt;
		colornames,&lt;br /&gt;
		',&amp;amp;nbsp;',&lt;br /&gt;
		#colornames == 2 and '&amp;amp;nbsp;and&amp;amp;nbsp;' or ',&amp;amp;nbsp;and&amp;amp;nbsp;'&lt;br /&gt;
	)&lt;br /&gt;
&lt;br /&gt;
	if (colors['cite']) then&lt;br /&gt;
		res = res .. frame:preprocess('&amp;lt;ref&amp;gt;' .. colors['cite'] .. '&amp;lt;/ref&amp;gt;')&lt;br /&gt;
	end&lt;br /&gt;
	if (colors['ref']) then&lt;br /&gt;
		res = res .. '[' .. colors['ref'] .. ']'&lt;br /&gt;
	end&lt;br /&gt;
	if (colors['ref2']) then&lt;br /&gt;
		res = res .. '[' .. colors['ref2'] .. ']'&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (#colornames &amp;gt; 0) then&lt;br /&gt;
		res = res .. sep&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (#colorboxes &amp;gt; 0) then&lt;br /&gt;
		res = res .. frame:extensionTag{ name = 'templatestyles', args = { src = 'Legend/styles.css'} }&lt;br /&gt;
		res = res .. table.concat(colorboxes, '&amp;amp;nbsp;')&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return res&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function team_check(team, unknown)&lt;br /&gt;
	local colors = get_colors(team, unknown)&lt;br /&gt;
	if type(colors) == 'table' then&lt;br /&gt;
		return 'known'&lt;br /&gt;
	else&lt;br /&gt;
		return unknown&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.color(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_color(remove_sport(args[1] or ''), args[2] or '', args[3] or '')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.color1(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_color(remove_sport(args[1] or ''), '1', '')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.color32(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_color(remove_sport(args[1] or ''), '3', '2')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.style1(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_style1(remove_sport(args[1] or ''), args['border'], args['color'])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.style2(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_style2(remove_sport(args[1] or ''), args['border'], args['color'])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.header1(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_header1(remove_sport(args[1] or ''), args['border'])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.header2(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_header2(remove_sport(args[1] or ''))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.tablehead1(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_table_head(args, remove_sport(args['team'] or ''), 'p')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.tablehead2(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_table_head(args, remove_sport(args['team'] or ''), 's')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.stripe1(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_stripe1(remove_sport(args[1] or ''), args['border'])&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.boxes(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_boxes(frame, remove_sport(args[1] or ''),&lt;br /&gt;
		args['order'] or '', args['sep'] or '&amp;amp;nbsp;')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.list(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_list(frame, remove_sport(args[1] or ''),&lt;br /&gt;
		args[2] or '1', args[3] or '2', args[4] or '3', args[5] or '4', args[6] or '5', args['sep'] or '')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.check(frame)&lt;br /&gt;
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args&lt;br /&gt;
	return team_check(remove_sport(args[1] or ''), args[2] or '')&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.check_data()&lt;br /&gt;
	-- In a sandbox, preview {{#invoke:college color|check_data}}&lt;br /&gt;
	local results = {'Problems in [[Module:College color/data]]:'}&lt;br /&gt;
	local function problems(msg)&lt;br /&gt;
		if msg then&lt;br /&gt;
			table.insert(results, msg)&lt;br /&gt;
		elseif results[2] then&lt;br /&gt;
			return table.concat(results, '\n*')&lt;br /&gt;
		else&lt;br /&gt;
			return 'No problems detected.'&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local data = require(data_module)&lt;br /&gt;
	local keys = {}&lt;br /&gt;
	for k, _ in pairs(data) do&lt;br /&gt;
		table.insert(keys, k)&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(keys)&lt;br /&gt;
	for _, key in ipairs(keys) do&lt;br /&gt;
		local val = data[key]&lt;br /&gt;
		if not (type(key) == 'string' and (type(val) == 'table' or type(val) == 'string')) then&lt;br /&gt;
			problems('Invalid type for &amp;quot;' .. tostring(key) .. '&amp;quot;')&lt;br /&gt;
		end&lt;br /&gt;
		if type(val) == 'table' then&lt;br /&gt;
			if not (2 &amp;lt;= #val and #val &amp;lt;= 4) then&lt;br /&gt;
				problems('Invalid number of numbered parameters for &amp;quot;' .. tostring(key) .. '&amp;quot;')&lt;br /&gt;
			end&lt;br /&gt;
			for i, v in ipairs(val) do&lt;br /&gt;
				if not tostring(v):match('^%x%x%x%x%x%x$') then&lt;br /&gt;
					problems('Parameter [' .. i .. '] should be a 6-hex-digit color but is &amp;quot;' .. tostring(v) .. '&amp;quot; for &amp;quot;' .. tostring(key) .. '&amp;quot;')&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			for k, v in pairs(val) do&lt;br /&gt;
				if type(k) == 'number' then&lt;br /&gt;
					if not (1 &amp;lt;= k and k &amp;lt;= 4) then&lt;br /&gt;
						problems('Invalid numbered parameter for &amp;quot;' .. tostring(key) .. '&amp;quot;')&lt;br /&gt;
					end&lt;br /&gt;
				elseif type(k) == 'string' then&lt;br /&gt;
					if not (&lt;br /&gt;
							k:match('^name[1-4]$') or&lt;br /&gt;
							k:match('^cite2?$') or&lt;br /&gt;
							k:match('^order$')&lt;br /&gt;
							) then&lt;br /&gt;
						problems('Unexpected key in table for &amp;quot;' .. tostring(key) .. '&amp;quot;')&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					problems('Invalid key type in table for &amp;quot;' .. tostring(key) .. '&amp;quot;')&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		elseif data[val] == nil then&lt;br /&gt;
			problems('Undefined alias for &amp;quot;' .. tostring(key) .. '&amp;quot;')&lt;br /&gt;
		elseif type(data[val]) ~= 'table' then&lt;br /&gt;
			problems('Alias is not a table for &amp;quot;' .. tostring(key) .. '&amp;quot;')&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return problems()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.testtable(frame)&lt;br /&gt;
	local contrasttable_mod = require(&amp;quot;Module:College color/contrast&amp;quot;)&lt;br /&gt;
	return contrasttable_mod._testtable(frame.args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>en&gt;Frietjes</name></author>
	</entry>
</feed>