Module:Party name with color
local p = {}
 local fetch = nil -- lazy load
 
 local function load_political_party_module()
 	if fetch == nil then
 		fetch = require('Module:Political party')._fetch
 	end
 end
 
 local function page_exist(page_name)
     if not page_name then return false end
     if mw.title.new(page_name).exists then return true end
     return false
 end
 
 local function simplify_rowspan(text)
 	text = mw.ustring.gsub(text or '', 'rowspan=&quot;1&quot;%s*', '')
 	return text
 end
 
 local function ifblank(one, two)
 	return (((one or &quot;&quot;) ~= &quot;&quot;) and one or two) or &quot;&quot;
 end
 
 local function getData(args)
 	local display_name = nil
 	local yesno = require('Module:Yesno')
 	if args[1] == &quot;Independent&quot; then
 		args[1] = &quot;Independent politician&quot;
 	end
 	if yesno(args.dab) == true then
 		display_name = args[1]
 	elseif yesno(args.full) == true then
 		display_name = mw.ustring.gsub(args[1], '%s+%b()$', '')
 	elseif args.shortname then
 		display_name = args.shortname
 	else
 		load_political_party_module()
 		if yesno(args.abbrev) then
 			display_name = fetch({args[1], 'abbrev'})
 		else
 			display_name = fetch({args[1], 'shortname'})
 		end
 	end
 	
 	if yesno(args.bold) == true then display_name = &quot;'''&quot; .. display_name .. &quot;'''&quot; end
 
 	local text = nil
 	if yesno(args.no_link) == true then
 		text = display_name
 	else
 		-- TODO: should this be on by default or do we want red links?
 		if page_exist(args[1]) then
 			text = string.format(&quot;[[%s|%s]]&quot;, args[1], display_name)
 		else
 			text = display_name
 		end
 	end
 
 	local color = args.colour or args.color
 	if not color then
 		load_political_party_module()
 		color = fetch({args[1], 'color'})
 	end
 	return text, color
 end
 
 function p._cell(args)
 	if not args[1] then return '' end
 	local text, color = getData(args)
 	
 	local line1 = 'rowspan=&quot;%s&quot; style=&quot;width: 2px; color:inherit; background-color: %s;&quot; data-sort-value=&quot;%s&quot; |\n'
 	local line2 = '| scope=&quot;row&quot; rowspan=&quot;%s&quot; style=&quot;text-align: left;&quot; | %s'
 	
 	local rowspan = tonumber(args.rowspan) or 1
 	line1 = string.format(line1, rowspan, color, args[1])
 	line2 = string.format(line2, rowspan, text)
 
 	return simplify_rowspan(line1 .. line2)
 end
 
 function p._box(args)
 	if not args[1] then return '' end
 	local text, color = getData(args)
 	
 	local seats
 	if args.seats then seats = ' (' .. args.seats .. ')' end
 	seats = seats or ''
 	
 	local outline = args.outline or 'black'
 	
 	local legend = '&lt;span class=&quot;legend nowrap&quot; style=&quot;page-break-inside:avoid;break-inside:avoid-column&quot;&gt;&lt;span class=&quot;legend-color&quot; style=&quot;display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;border:1px solid ' .. outline .. ';background-color:' .. color .. '&quot;&gt; &lt;/span&gt; ' .. text .. seats .. '&lt;/span&gt;'
 	return legend
 end
 
 function p.cell(frame)
 	local getArgs = require('Module:Arguments').getArgs
 	local args = getArgs(frame)
 	local check = require('Module:Check for unknown parameters')._check
 	local tracking = check({
 		['unknown']='[[Category:Pages using Party name with color with unknown parameters|_VALUE_ ]]',
 		['preview']='Page using [[Template:Party name with color]] with unknown parameter &quot;_VALUE_&quot;',
 		['showblankpositional']='1',
 		'1', 'abbrev', 'color', 'colour', 'dab', 'full', 'no_link', 'rowspan', 'shortname', 'bold'
 	}, frame:getParent().args)
 	return p._cell(args) .. tracking
 end
 
 function p.box(frame)
 	local getArgs = require('Module:Arguments').getArgs
 	local args = getArgs(frame)
 	return p._box(args)
 end