<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.stiles.casa/index.php?action=history&amp;feed=atom&amp;title=Module%3AEpisode_list%2Fsandbox</id>
	<title>Module:Episode list/sandbox - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.stiles.casa/index.php?action=history&amp;feed=atom&amp;title=Module%3AEpisode_list%2Fsandbox"/>
	<link rel="alternate" type="text/html" href="https://wiki.stiles.casa/index.php?title=Module:Episode_list/sandbox&amp;action=history"/>
	<updated>2026-04-07T11:16:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.2</generator>
	<entry>
		<id>https://wiki.stiles.casa/index.php?title=Module:Episode_list/sandbox&amp;diff=7332&amp;oldid=prev</id>
		<title>imported&gt;GKFX: Copy from Module:Episode list</title>
		<link rel="alternate" type="text/html" href="https://wiki.stiles.casa/index.php?title=Module:Episode_list/sandbox&amp;diff=7332&amp;oldid=prev"/>
		<updated>2022-01-20T19:24:36Z</updated>

		<summary type="html">&lt;p&gt;Copy from &lt;a href=&quot;/view/Module:Episode_list&quot; title=&quot;Module:Episode list&quot;&gt;Module:Episode list&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
-- This module requires the use of the following modules:&lt;br /&gt;
local colorContrastModule = require(&amp;#039;Module:Color contrast&amp;#039;)&lt;br /&gt;
local htmlColor = mw.loadData(&amp;#039;Module:Color contrast/colors&amp;#039;)&lt;br /&gt;
local delinkModule = require(&amp;#039;Module:Delink&amp;#039;)&lt;br /&gt;
local langModule = require(&amp;quot;Module:Lang&amp;quot;)&lt;br /&gt;
local mathModule = require(&amp;#039;Module:Math&amp;#039;)&lt;br /&gt;
local tableEmptyCellModule = require(&amp;#039;Module:Table empty cell&amp;#039;)&lt;br /&gt;
local yesNoModule = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
-- mw.html object for the generated row.&lt;br /&gt;
local row&lt;br /&gt;
&lt;br /&gt;
-- Variable that will decide the colspan= of the Short Summary cell.&lt;br /&gt;
local nonNilParams = 0&lt;br /&gt;
&lt;br /&gt;
-- Variable that will keep track if a TBA value was entered.&lt;br /&gt;
local cellValueTBA = false&lt;br /&gt;
&lt;br /&gt;
-- Variable that handles the assigned tracking categories.&lt;br /&gt;
local trackingCategories = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- List of tracking categories.&lt;br /&gt;
local trackingCategoryList = {&lt;br /&gt;
	[&amp;quot;air_dates&amp;quot;] = &amp;quot;[[Category:Episode lists with unformatted air dates]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;alt_air_dates&amp;quot;] = &amp;quot;[[Category:Episode lists with incorrectly formatted alternate air dates]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;faulty_line_colors&amp;quot;] = &amp;quot;[[Category:Episode lists with faulty line colors]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;non_compliant_line_colors&amp;quot;] = &amp;quot;[[Category:Episode lists with non-compliant line colors]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;default_line_colors&amp;quot;] = &amp;quot;[[Category:Episode list using the default LineColor]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;row_deviations&amp;quot;] = &amp;quot;[[Category:Episode lists with row deviations]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;invalid_top_colors&amp;quot;] = &amp;quot;[[Category:Episode lists with invalid top colors]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;tba_values&amp;quot;] = &amp;quot;[[Category:Episode lists with TBA values]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;nonmatching_numbered_parameters&amp;quot;] = &amp;quot;[[Category:Episode lists with a non-matching set of numbered parameters]]&amp;quot;,&lt;br /&gt;
	[&amp;quot;raw_unformatted_storyteleplay&amp;quot;] = &amp;quot;[[Category:Episode lists with unformatted story or teleplay credits]]&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- List of parameter names in this order.&lt;br /&gt;
local cellNameList = {&lt;br /&gt;
	&amp;#039;Aux1&amp;#039;,&lt;br /&gt;
	&amp;#039;DirectedBy&amp;#039;,&lt;br /&gt;
	&amp;#039;WrittenBy&amp;#039;,&lt;br /&gt;
	&amp;#039;Aux2&amp;#039;,&lt;br /&gt;
	&amp;#039;Aux3&amp;#039;,&lt;br /&gt;
	&amp;#039;OriginalAirDate&amp;#039;,&lt;br /&gt;
	&amp;#039;AltDate&amp;#039;,&lt;br /&gt;
	&amp;#039;Guests&amp;#039;,&lt;br /&gt;
	&amp;#039;MusicalGuests&amp;#039;,&lt;br /&gt;
	&amp;#039;ProdCode&amp;#039;,&lt;br /&gt;
	&amp;#039;Viewers&amp;#039;,&lt;br /&gt;
	&amp;#039;Aux4&amp;#039;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- List of pairs which cannot be used together&lt;br /&gt;
local excludeList = {&lt;br /&gt;
	[&amp;#039;Guests&amp;#039;] = &amp;#039;Aux1&amp;#039;,&lt;br /&gt;
	[&amp;#039;MusicalGuests&amp;#039;] = &amp;#039;Aux2&amp;#039;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- List of cells that have parameter groups&lt;br /&gt;
local parameterGroupCells = {}&lt;br /&gt;
local firstParameterGroupCell&lt;br /&gt;
&lt;br /&gt;
-- List of title parameter names in this order.&lt;br /&gt;
-- List used for multi title lists.&lt;br /&gt;
local titleList = {&lt;br /&gt;
	&amp;#039;Title&amp;#039;,&lt;br /&gt;
	&amp;#039;RTitle&amp;#039;,&lt;br /&gt;
	&amp;#039;AltTitle&amp;#039;,&lt;br /&gt;
	&amp;#039;RAltTitle&amp;#039;,&lt;br /&gt;
	&amp;#039;NativeTitle&amp;#039;,&lt;br /&gt;
	&amp;#039;TranslitTitle&amp;#039;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to retrieve the episode number or production code number,&lt;br /&gt;
-- without any additional text.&lt;br /&gt;
local function idTrim(val, search)&lt;br /&gt;
	local valFind = string.find(val, search)&lt;br /&gt;
&lt;br /&gt;
	if (valFind == nil) then&lt;br /&gt;
		return val&lt;br /&gt;
	else&lt;br /&gt;
		return string.sub(val, 0, valFind-1)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to validate that a parameter has an actual value.&lt;br /&gt;
local function hasValue(param)&lt;br /&gt;
	if (param ~= nil and param ~= &amp;quot;&amp;quot;) then&lt;br /&gt;
		return true&lt;br /&gt;
	else&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create a table data cell.&lt;br /&gt;
local function createTableData(text, rowSpan, textAlign)&lt;br /&gt;
	if (rowSpan ~= nil and tonumber(rowSpan) &amp;gt; 1) then&lt;br /&gt;
		row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;rowspan&amp;#039;, rowSpan)&lt;br /&gt;
			:wikitext(text)&lt;br /&gt;
	else&lt;br /&gt;
		row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:css(&amp;#039;text-align&amp;#039;, textAlign)&lt;br /&gt;
			:wikitext(text)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to add a tracking category to the page.&lt;br /&gt;
local function addTrackingCategory(category)&lt;br /&gt;
	trackingCategories = trackingCategories .. category&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create a Short Summary row.&lt;br /&gt;
local function createShortSummaryRow(args, lineColor)&lt;br /&gt;
	-- fix for lists in the Short Summary&lt;br /&gt;
	local shortSummaryText = args.ShortSummary&lt;br /&gt;
&lt;br /&gt;
	if (shortSummaryText:match(&amp;#039;^[*:;#]&amp;#039;) or shortSummaryText:match(&amp;#039;^{|&amp;#039;)) then&lt;br /&gt;
		shortSummaryText = &amp;#039;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;\n&amp;#039; .. shortSummaryText&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (shortSummaryText:match(&amp;#039;\n[*:;#]&amp;#039;)) then&lt;br /&gt;
		shortSummaryText = shortSummaryText .. &amp;#039;\n&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local shortSummaryCell = mw.html.create(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:addClass(&amp;#039;description&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;border-bottom&amp;#039;, &amp;#039;solid 3px &amp;#039; .. lineColor)&lt;br /&gt;
				:attr(&amp;#039;colspan&amp;#039;, nonNilParams)&lt;br /&gt;
				:newline()&lt;br /&gt;
				:wikitext(shortSummaryText)&lt;br /&gt;
&lt;br /&gt;
	return mw.html.create(&amp;#039;tr&amp;#039;)&lt;br /&gt;
					:addClass(&amp;#039;expand-child&amp;#039;)&lt;br /&gt;
					:node(shortSummaryCell)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to add tracking categories for Top Color issues.&lt;br /&gt;
local function addTopColorTrackingCategories(args)&lt;br /&gt;
	if (hasValue(args.TopColor)) then&lt;br /&gt;
		addTrackingCategory(trackingCategoryList[&amp;quot;row_deviations&amp;quot;])&lt;br /&gt;
&lt;br /&gt;
		-- Track top colors that have a color contrast rating below AAA with&lt;br /&gt;
		-- respect to text color, link color, or visited link color. See&lt;br /&gt;
		-- [[SW:COLOR]] for more about color contrast requirements.&lt;br /&gt;
		local textContrastRatio = colorContrastModule._ratio{args.TopColor, &amp;#039;black&amp;#039;, [&amp;#039;error&amp;#039;] = 0}&lt;br /&gt;
		local linkContrastRatio = colorContrastModule._ratio{args.TopColor, &amp;#039;#0B0080&amp;#039;, [&amp;#039;error&amp;#039;] = 0}&lt;br /&gt;
		local visitedLinkContrastRatio = colorContrastModule._ratio{args.TopColor, &amp;#039;#0645AD&amp;#039;, [&amp;#039;error&amp;#039;] = 0}&lt;br /&gt;
&lt;br /&gt;
		if (textContrastRatio &amp;lt; 7 or linkContrastRatio &amp;lt; 7 or visitedLinkContrastRatio &amp;lt; 7) then&lt;br /&gt;
			addTrackingCategory(trackingCategoryList[&amp;quot;invalid_top_colors&amp;quot;])&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to add tracking categories for Line Color issues.&lt;br /&gt;
local function addLineColorTrackingCategories(args)&lt;br /&gt;
	if (hasValue(args.LineColor)) then&lt;br /&gt;
		local blackContrastRatio = colorContrastModule._ratio{args.LineColor, &amp;#039;black&amp;#039;, [&amp;#039;error&amp;#039;] = 0}&lt;br /&gt;
		local whiteContrastRatio = colorContrastModule._ratio{&amp;#039;white&amp;#039;, args.LineColor, [&amp;#039;error&amp;#039;] = 0}&lt;br /&gt;
&lt;br /&gt;
		if (colorContrastModule._lum(args.LineColor) == &amp;#039;&amp;#039;) then&lt;br /&gt;
			addTrackingCategory(trackingCategoryList[&amp;quot;faulty_line_colors&amp;quot;])&lt;br /&gt;
		elseif (blackContrastRatio &amp;lt; 7 and whiteContrastRatio &amp;lt; 7) then&lt;br /&gt;
			addTrackingCategory(trackingCategoryList[&amp;quot;non_compliant_line_colors&amp;quot;])&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		addTrackingCategory(trackingCategoryList[&amp;quot;default_line_colors&amp;quot;])&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to remove wiki-links from repated information in rowspans.&lt;br /&gt;
-- Used for Doctor Who serials, where the director and writer are the same for each part of serial.&lt;br /&gt;
local function removeWikilinks(args, v)&lt;br /&gt;
	return delinkModule._delink{args[v]}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to set the text of an empty cell&lt;br /&gt;
-- with either &amp;quot;TBD&amp;quot; or &amp;quot;N/A&amp;quot;.&lt;br /&gt;
-- Set to N/A if viewers haven&amp;#039;t been available for four weeks, else set it as TBD.&lt;br /&gt;
local function setTBDStatus(args)&lt;br /&gt;
	local month, day, year = args.OriginalAirDate:gsub(&amp;quot;&amp;amp;nbsp;&amp;quot;, &amp;quot; &amp;quot;):match(&amp;quot;(%a+) (%d+), (%d+)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if (month == nil) then&lt;br /&gt;
		day, month, year = args.OriginalAirDate:gsub(&amp;quot;&amp;amp;nbsp;&amp;quot;, &amp;quot; &amp;quot;):match(&amp;quot;(%d+) (%a+) (%d+)&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (day == nil) then&lt;br /&gt;
		return tableEmptyCellModule._main({alt_text = &amp;quot;TBD&amp;quot;})&lt;br /&gt;
	else&lt;br /&gt;
		-- List of months.&lt;br /&gt;
		local monthList = {&lt;br /&gt;
			[&amp;#039;January&amp;#039;] = 1,&lt;br /&gt;
			[&amp;#039;February&amp;#039;] = 2,&lt;br /&gt;
			[&amp;#039;March&amp;#039;] = 3,&lt;br /&gt;
			[&amp;#039;April&amp;#039;] = 4,&lt;br /&gt;
			[&amp;#039;May&amp;#039;] = 5,&lt;br /&gt;
			[&amp;#039;June&amp;#039;] = 6,&lt;br /&gt;
			[&amp;#039;July&amp;#039;] = 7,&lt;br /&gt;
			[&amp;#039;August&amp;#039;] = 8,&lt;br /&gt;
			[&amp;#039;September&amp;#039;] = 9,&lt;br /&gt;
			[&amp;#039;October&amp;#039;] = 10,&lt;br /&gt;
			[&amp;#039;November&amp;#039;] = 11,&lt;br /&gt;
			[&amp;#039;December&amp;#039;] = 12&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		if not monthList[month] then&lt;br /&gt;
			error(&amp;#039;Invalid month &amp;#039; .. month)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		local seconds = os.time() - os.time({year = year, month = monthList[month], day = day, hour = 0, min = 0, sec = 0})&lt;br /&gt;
&lt;br /&gt;
		if (seconds &amp;gt;= 60 * 60 * 24 * 7 * 4) then&lt;br /&gt;
			return tableEmptyCellModule._main({alt_text = &amp;quot;N/A&amp;quot;})&lt;br /&gt;
		else&lt;br /&gt;
			return tableEmptyCellModule._main({alt_text = &amp;quot;TBD&amp;quot;})&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create an empty cell.&lt;br /&gt;
local function createEmptyCell(args, v, unsetParameterGroup)&lt;br /&gt;
	if (unsetParameterGroup) then&lt;br /&gt;
		args[v] = tableEmptyCellModule._main({alt_text = &amp;quot;N/A&amp;quot;})&lt;br /&gt;
	elseif (v == &amp;#039;Viewers&amp;#039; and hasValue(args.OriginalAirDate)) then&lt;br /&gt;
		args[v] = setTBDStatus(args)&lt;br /&gt;
	else&lt;br /&gt;
		args[v] = tableEmptyCellModule._main({})&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Air dates that don&amp;#039;t use {{Start date}}&lt;br /&gt;
local function checkUsageOfDateTemplates(args, v, onInitialPage, title)&lt;br /&gt;
	if (v == &amp;#039;OriginalAirDate&amp;#039;&lt;br /&gt;
		and args[v] ~= &amp;#039;&amp;#039;&lt;br /&gt;
		and string.match(args[v], &amp;#039;%d%d%d%d&amp;#039;) ~= nil&lt;br /&gt;
		and string.match(args[v], &amp;#039;2C2C2C&amp;#039;) == nil&lt;br /&gt;
		and string.find(args[v], &amp;#039;dtstart&amp;#039;) == nil&lt;br /&gt;
		and onInitialPage&lt;br /&gt;
		and title.namespace == 0)&lt;br /&gt;
	then&lt;br /&gt;
		addTrackingCategory(trackingCategoryList[&amp;quot;air_dates&amp;quot;])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Alternate air dates that do use {{Start date}}&lt;br /&gt;
	if (v == &amp;#039;AltDate&amp;#039; and args[v] ~= &amp;#039;&amp;#039; and string.find(args[v], &amp;#039;dtstart&amp;#039;) ~= nil and onInitialPage and title.namespace == 0) then&lt;br /&gt;
		addTrackingCategory(trackingCategoryList[&amp;quot;alt_air_dates&amp;quot;])&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create a Production Code cell.&lt;br /&gt;
local function createProductionCodeCell(args, v)&lt;br /&gt;
	if (hasValue(args.ProdCode) and string.find(args.ProdCode, &amp;#039;TBA&amp;#039;) == nil) then&lt;br /&gt;
		row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;id&amp;#039;, &amp;#039;pc&amp;#039; .. idTrim(idTrim(args.ProdCode, &amp;#039; ----&amp;#039;), &amp;#039;&amp;lt;&amp;#039;))&lt;br /&gt;
			:wikitext(args.ProdCode)&lt;br /&gt;
	elseif (args.ProdCode == &amp;#039;&amp;#039; or string.find(args.ProdCode or &amp;#039;&amp;#039;, &amp;#039;TBA&amp;#039;) ~= nil) then&lt;br /&gt;
		createEmptyCell(args, v, false)&lt;br /&gt;
		createTableData(args.ProdCode, 1, nil)&lt;br /&gt;
	else&lt;br /&gt;
		-- ProductionCode parameter not used; Do nothing.&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	nonNilParams = nonNilParams + 1&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Local function which is used to extract data&lt;br /&gt;
from the numbered serial parameters (Title1, Aux1, etc.), and then convert them to&lt;br /&gt;
use the non-numbered parameter names (Title, Aux).&lt;br /&gt;
&lt;br /&gt;
The function returns the args as non-numbered prameter names.&lt;br /&gt;
]]--&lt;br /&gt;
local function extractDataFromNumberedSerialArgs(args, i, numberOfParameterGroups, title)&lt;br /&gt;
	for _, v in ipairs(cellNameList) do&lt;br /&gt;
		local parameter = v&lt;br /&gt;
		local numberedParameter = v .. &amp;quot;_&amp;quot; .. i&lt;br /&gt;
		local excludeParameter = excludeList[parameter] or &amp;#039;NULL&amp;#039; .. parameter&lt;br /&gt;
		local excludeNumberParameter = (excludeList[numberedParameter] or &amp;#039;NULL&amp;#039; .. parameter) .. &amp;quot;_&amp;quot; .. i&lt;br /&gt;
		if (not hasValue(args[numberedParameter]) and not hasValue(args[excludeNumberParameter])&lt;br /&gt;
			and hasValue(parameterGroupCells[parameter]) and not hasValue(args[excludeParameter])) then&lt;br /&gt;
			if (v ~= &amp;#039;ProdCode&amp;#039;) then&lt;br /&gt;
				createEmptyCell(args, parameter, true)&lt;br /&gt;
			else&lt;br /&gt;
				args[parameter] = &amp;#039;&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
			if (title.namespace == 0) then&lt;br /&gt;
				addTrackingCategory(trackingCategoryList[&amp;quot;nonmatching_numbered_parameters&amp;quot;])&lt;br /&gt;
			end&lt;br /&gt;
		elseif (hasValue(args[numberedParameter]) and not  hasValue(args[excludeNumberParameter])) then&lt;br /&gt;
			args[parameter] = args[numberedParameter]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return args&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Local function which is used to create column cells.&lt;br /&gt;
&lt;br /&gt;
EpisodeNumber, EpisodeNumber2 and Title are created in different functions&lt;br /&gt;
as they require some various if checks.&lt;br /&gt;
&lt;br /&gt;
See:&lt;br /&gt;
	-- createEpisodeNumberCell()&lt;br /&gt;
	-- createEpisodeNumberCellSecondary()&lt;br /&gt;
	-- createTitleCell()&lt;br /&gt;
]]--&lt;br /&gt;
local function createCells(args, isSerial, currentRow, onInitialPage, title, numberOfParameterGroups)&lt;br /&gt;
	for k, v in ipairs(cellNameList) do&lt;br /&gt;
		if (v == &amp;#039;ProdCode&amp;#039;) then&lt;br /&gt;
			createProductionCodeCell(args, v)&lt;br /&gt;
		elseif (args[v]) then&lt;br /&gt;
			-- Set empty cells to TBA/TBD&lt;br /&gt;
			if (args[v] == &amp;#039;&amp;#039;) then&lt;br /&gt;
				createEmptyCell(args, v, false)&lt;br /&gt;
			elseif (v == &amp;#039;WrittenBy&amp;#039; and title.namespace == 0) then&lt;br /&gt;
				if ((string.find(args[v], &amp;quot;&amp;#039;&amp;#039;Story&amp;quot;) ~= nil or string.find(args[v], &amp;quot;&amp;#039;&amp;#039;Teleplay&amp;quot;) ~= nil) and string.find(args[v], &amp;quot;8202&amp;quot;) == nil) then&lt;br /&gt;
					-- &amp;amp;#8202; is the hairspace added through {{StoryTeleplay}}&lt;br /&gt;
					addTrackingCategory(trackingCategoryList[&amp;quot;raw_unformatted_storyteleplay&amp;quot;])&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- If serial titles need to be centered and not left, then this should be removed.&lt;br /&gt;
			local textAlign = nil -- default from stylesheet is center&lt;br /&gt;
			if (v == &amp;#039;Aux1&amp;#039; and isSerial) then&lt;br /&gt;
				textAlign = &amp;quot;left&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- Remove wikilinks from links in serial rowspans rows after the first.&lt;br /&gt;
			-- if (currentRow &amp;gt; 1) then&lt;br /&gt;
				-- args[v] = removeWikilinks(args, v)&lt;br /&gt;
			-- end&lt;br /&gt;
&lt;br /&gt;
			local thisRowspan&lt;br /&gt;
			if (firstParameterGroupCell and k &amp;lt; firstParameterGroupCell) then&lt;br /&gt;
				thisRowspan = numberOfParameterGroups&lt;br /&gt;
			else&lt;br /&gt;
				thisRowspan = 1&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if (currentRow == 1 or (currentRow &amp;gt; 1 and k &amp;gt;= (firstParameterGroupCell or 0))) then&lt;br /&gt;
				createTableData(args[v], thisRowspan, textAlign)&lt;br /&gt;
			end&lt;br /&gt;
			nonNilParams = nonNilParams + 1&lt;br /&gt;
			checkUsageOfDateTemplates(args, v, onInitialPage, title)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if (args[v] == &amp;quot;TBA&amp;quot;) then&lt;br /&gt;
			cellValueTBA = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Local function which is used to create the Title cell text.&lt;br /&gt;
&lt;br /&gt;
The title text will be handled in the following way:&lt;br /&gt;
	Line 1: &amp;lt;Title&amp;gt;&amp;lt;RTitle&amp;gt; (with no space between)&lt;br /&gt;
	Line 2: &amp;lt;AltTitle&amp;gt;&amp;lt;RAltTitle&amp;gt; (with no space between) OR&lt;br /&gt;
	Line 2: Transcription: &amp;lt;TranslitTitle&amp;gt; (&amp;lt;Language&amp;gt;: &amp;lt;NativeTitle&amp;gt;)&amp;lt;RAltTitle&amp;gt; (with space between first two parameters)&lt;br /&gt;
&lt;br /&gt;
	If &amp;lt;Title&amp;gt; or &amp;lt;RTitle&amp;gt; are empty,&lt;br /&gt;
	then the values of line 2 will be placed on line 1 instead.&lt;br /&gt;
&lt;br /&gt;
--]]&lt;br /&gt;
local function createTitleText(args)&lt;br /&gt;
	local titleString = &amp;#039;&amp;#039;&lt;br /&gt;
	local isCellPresent = false&lt;br /&gt;
	local useSecondLine = false&lt;br /&gt;
	local lineBreakUsed = false&lt;br /&gt;
&lt;br /&gt;
	-- Surround the Title with quotes; No quotes if empty.&lt;br /&gt;
	if (args.Title ~= nil) then&lt;br /&gt;
		if (args.Title == &amp;quot;&amp;quot;) then&lt;br /&gt;
			isCellPresent = true&lt;br /&gt;
		else&lt;br /&gt;
			titleString = &amp;#039;&amp;quot;&amp;#039; .. args.Title .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
			useSecondLine = true&lt;br /&gt;
			isCellPresent = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (args.RTitle ~= nil) then&lt;br /&gt;
		if (args.RTitle == &amp;quot;&amp;quot;) then&lt;br /&gt;
			isCellPresent = true&lt;br /&gt;
		else&lt;br /&gt;
			titleString = titleString .. args.RTitle&lt;br /&gt;
			useSecondLine = true&lt;br /&gt;
			isCellPresent = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Surround the AltTitle/TranslitTitle with quotes; No quotes if empty.&lt;br /&gt;
	if (args.AltTitle or args.TranslitTitle) then&lt;br /&gt;
&lt;br /&gt;
		isCellPresent = true&lt;br /&gt;
&lt;br /&gt;
		if (useSecondLine) then&lt;br /&gt;
			titleString = titleString .. &amp;quot;&amp;lt;br /&amp;gt;&amp;quot;&lt;br /&gt;
			lineBreakUsed = true&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if (hasValue(args.AltTitle)) then&lt;br /&gt;
			titleString = titleString .. &amp;#039;&amp;quot;&amp;#039; .. args.AltTitle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
		elseif (hasValue(args.TranslitTitle)) then&lt;br /&gt;
			if (hasValue(args.NativeTitleLangCode)) then&lt;br /&gt;
				titleString = titleString .. &amp;#039;Transcription: &amp;quot;&amp;#039; .. langModule._transl({args.NativeTitleLangCode, args.TranslitTitle, italic = &amp;#039;no&amp;#039;})  .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
			else&lt;br /&gt;
				titleString = titleString .. &amp;#039;Transcription: &amp;quot;&amp;#039; .. args.TranslitTitle .. &amp;#039;&amp;quot;&amp;#039;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (args.NativeTitle ~= nil) then&lt;br /&gt;
		if (args.NativeTitle == &amp;quot;&amp;quot;) then&lt;br /&gt;
			isCellPresent = true&lt;br /&gt;
		else&lt;br /&gt;
			isCellPresent = true&lt;br /&gt;
&lt;br /&gt;
			if (useSecondLine and lineBreakUsed == false) then&lt;br /&gt;
				titleString = titleString .. &amp;quot;&amp;lt;br /&amp;gt;&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			if (hasValue(args.NativeTitleLangCode)) then&lt;br /&gt;
				local languageCode = &amp;quot;Lang-&amp;quot; .. args.NativeTitleLangCode&lt;br /&gt;
				titleString = titleString .. &amp;quot; (&amp;quot; .. langModule._lang_xx_inherit({code = args.NativeTitleLangCode, args.NativeTitle}) .. &amp;quot;)&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				titleString = titleString .. &amp;quot; (&amp;quot; .. args.NativeTitle .. &amp;quot;)&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (args.RAltTitle ~= nil) then&lt;br /&gt;
		if (args.RAltTitle == &amp;quot;&amp;quot;) then&lt;br /&gt;
			isCellPresent = true&lt;br /&gt;
		else&lt;br /&gt;
			isCellPresent = true&lt;br /&gt;
&lt;br /&gt;
			if (useSecondLine and lineBreakUsed == false) then&lt;br /&gt;
				titleString = titleString .. &amp;quot;&amp;lt;br /&amp;gt;&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			titleString = titleString .. args.RAltTitle&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return titleString, isCellPresent&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Local function which is used to extract data&lt;br /&gt;
from the numbered title parameters (Title1, RTitle2, etc.), and then convert them to&lt;br /&gt;
use the non-numbered prameter names (Title, RTitle).&lt;br /&gt;
&lt;br /&gt;
The function returns two results:&lt;br /&gt;
	-- The args parameter table.&lt;br /&gt;
	-- A boolean indicating if the title group has data.&lt;br /&gt;
]]--&lt;br /&gt;
local function extractDataFromNumberedTitleArgs(args, i)&lt;br /&gt;
	local nextGroupValid = false&lt;br /&gt;
&lt;br /&gt;
	for _, v in ipairs(titleList) do&lt;br /&gt;
		local parameter = v&lt;br /&gt;
		local numberedParameter = v .. &amp;quot;_&amp;quot; .. i&lt;br /&gt;
		args[parameter] = args[numberedParameter]&lt;br /&gt;
&lt;br /&gt;
		if (nextGroupValid == false and hasValue(args[numberedParameter])) then&lt;br /&gt;
			nextGroupValid = true&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return args, nextGroupValid&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to process the multi title list.&lt;br /&gt;
local function processMultiTitleList(args, numberOfParameterGroups)&lt;br /&gt;
	local nativeTitleLangCode = args.NativeTitleLangCode&lt;br /&gt;
	local titleText = &amp;quot;&amp;quot;&lt;br /&gt;
	local isCellPresent = false&lt;br /&gt;
	local isFirstTitleGroup = true -- Making sure that the title cell is created at least once and isn&amp;#039;t created again if other #N titles are empty.&lt;br /&gt;
&lt;br /&gt;
	for i = 1, numberOfParameterGroups do&lt;br /&gt;
		local args, nextGroupValid = extractDataFromNumberedTitleArgs(args, i)&lt;br /&gt;
		if (nextGroupValid) then&lt;br /&gt;
			if (isFirstTitleGroup == false) then&lt;br /&gt;
				titleText = titleText .. &amp;quot;&amp;lt;hr /&amp;gt;&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			local titleTextRow&lt;br /&gt;
			titleTextRow = createTitleText(args)&lt;br /&gt;
			titleText = titleText .. titleTextRow&lt;br /&gt;
			isFirstTitleGroup = false&lt;br /&gt;
		else&lt;br /&gt;
			if (isFirstTitleGroup) then&lt;br /&gt;
				titleText, isCellPresent = createTitleText(args)&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
			-- Valid titles have to be in succession (#1, #2, #3 and not #1, #4 #5), so exit for loop if next group is empty.&lt;br /&gt;
			return titleText, isCellPresent&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return titleText&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create a Title cell.&lt;br /&gt;
local function createTitleCell(args, numberOfParameterGroups, multiTitleListEnabled, isSerial)&lt;br /&gt;
	local titleText&lt;br /&gt;
	local isCellPresent&lt;br /&gt;
&lt;br /&gt;
	if (multiTitleListEnabled) then&lt;br /&gt;
		titleText, isCellPresent = processMultiTitleList(args, numberOfParameterGroups)&lt;br /&gt;
	else&lt;br /&gt;
		titleText, isCellPresent = createTitleText(args)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (isCellPresent == false) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If Title is blank, then set Raw Title to TBA&lt;br /&gt;
	if (hasValue(titleText) == false) then&lt;br /&gt;
		titleText = tableEmptyCellModule._main({})&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If title is the first cell, create it with a !scope=&amp;quot;row&amp;quot;&lt;br /&gt;
	if (nonNilParams == 0) then&lt;br /&gt;
		if (isSerial) then&lt;br /&gt;
			row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
				:addClass(&amp;#039;summary&amp;#039;)&lt;br /&gt;
				:attr(&amp;#039;scope&amp;#039;, &amp;#039;row&amp;#039;)&lt;br /&gt;
				:attr(&amp;#039;rowspan&amp;#039;, numberOfParameterGroups)&lt;br /&gt;
				:wikitext(titleText)&lt;br /&gt;
		else&lt;br /&gt;
			row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
				:addClass(&amp;#039;summary&amp;#039;)&lt;br /&gt;
				:attr(&amp;#039;scope&amp;#039;, &amp;#039;row&amp;#039;)&lt;br /&gt;
				:wikitext(titleText)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		if (isSerial) then&lt;br /&gt;
			row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:addClass(&amp;#039;summary&amp;#039;)&lt;br /&gt;
				:attr(&amp;#039;rowspan&amp;#039;, numberOfParameterGroups)&lt;br /&gt;
				:wikitext(titleText)&lt;br /&gt;
		else&lt;br /&gt;
			row:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:addClass(&amp;#039;summary&amp;#039;)&lt;br /&gt;
				:wikitext(titleText)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	nonNilParams = nonNilParams + 1&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create a table row header for either the&lt;br /&gt;
-- EpisodeNumber or EpisodeNumber2 column cells.&lt;br /&gt;
local function createTableRowEpisodeNumberHeader(episodeNumber, numberOfParameterGroups, episodeText)&lt;br /&gt;
		local epID = string.match(episodeNumber, &amp;quot;^%w+&amp;quot;)&lt;br /&gt;
		row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;scope&amp;#039;, &amp;#039;row&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;rowspan&amp;#039;, numberOfParameterGroups)&lt;br /&gt;
			:attr(&amp;#039;id&amp;#039;, epID and &amp;#039;ep&amp;#039; .. epID or &amp;#039;&amp;#039;)&lt;br /&gt;
			:wikitext(episodeText)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Local function which is used to extract the text from the EpisodeNumber or EpisodeNumber2&lt;br /&gt;
parameters and format them into a correct MoS compliant version.&lt;br /&gt;
&lt;br /&gt;
Styles supported:&lt;br /&gt;
	-- A number range of two numbers, indicating the start and end of the range,&lt;br /&gt;
	seperated by an en-dash (–) with no spaces in between.&lt;br /&gt;
		Example: &amp;quot;1 - 2&amp;quot; -&amp;gt; &amp;quot;1–2&amp;quot;; &amp;quot;1-2-3&amp;quot; -&amp;gt; &amp;quot;1–3&amp;quot;.&lt;br /&gt;
	-- An alphanumeric or letter range, similar to the above.&lt;br /&gt;
		Example: &amp;quot;A - B&amp;quot; -&amp;gt; &amp;quot;A–B&amp;quot;; &amp;quot;A-B-C&amp;quot; -&amp;gt; &amp;quot;A–C&amp;quot;.&lt;br /&gt;
		Example: &amp;quot;A1 - B1&amp;quot; -&amp;gt; &amp;quot;A1–B1&amp;quot;; &amp;quot;A1-B1-C1&amp;quot; -&amp;gt; &amp;quot;A1–C1&amp;quot;.&lt;br /&gt;
	-- A number range of two numbers, indicating the start and end of the range,&lt;br /&gt;
	seperated by a visual &amp;lt;hr /&amp;gt; (divider line).&lt;br /&gt;
	-- An alphanumeric or letter range, similar to the above.&lt;br /&gt;
]]--&lt;br /&gt;
local function getEpisodeText(episodeNumber)&lt;br /&gt;
	if (episodeNumber == &amp;#039;&amp;#039;) then&lt;br /&gt;
		return tableEmptyCellModule._main({})&lt;br /&gt;
	else&lt;br /&gt;
&lt;br /&gt;
		local episodeNumber1&lt;br /&gt;
		local episodeNumber2&lt;br /&gt;
&lt;br /&gt;
		-- Used for double episodes that need a visual &amp;quot;–&amp;quot;&amp;quot; or &amp;quot;&amp;lt;hr /&amp;gt;&amp;quot;&amp;quot; added.&lt;br /&gt;
		local divider&lt;br /&gt;
&lt;br /&gt;
		episodeNumber = episodeNumber:gsub(&amp;#039;%s*&amp;lt;br%s*/?%s*&amp;gt;%s*&amp;#039;, &amp;#039;&amp;lt;hr /&amp;gt;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
		if (episodeNumber:match(&amp;#039;^(%w+)%s*&amp;lt;hr */%s*&amp;gt;%s*(%w+)$&amp;#039;)) then&lt;br /&gt;
			episodeNumber1, episodeNumber2 = episodeNumber:match(&amp;#039;^(%w+)%s*&amp;lt;hr */%s*&amp;gt;%s*(%w+)$&amp;#039;)&lt;br /&gt;
			divider = &amp;quot;&amp;lt;hr /&amp;gt;&amp;quot;&lt;br /&gt;
		elseif (episodeNumber:match(&amp;#039;^(%w+)%s*&amp;lt;hr */%s*&amp;gt;.-&amp;lt;hr */%s*&amp;gt;%s*(%w+)$&amp;#039;)) then  -- 3 or more elements&lt;br /&gt;
			episodeNumber1, episodeNumber2 = episodeNumber:match(&amp;#039;^(%w+)%s*&amp;lt;hr */%s*&amp;gt;.-&amp;lt;hr */%s*&amp;gt;%s*(%w+)$&amp;#039;)&lt;br /&gt;
			divider = &amp;quot;&amp;lt;hr /&amp;gt;&amp;quot;&lt;br /&gt;
		elseif (mw.ustring.match(episodeNumber, &amp;#039;^(%w+)%s*[%s%-–/&amp;amp;]%s*(%w+)$&amp;#039;)) then&lt;br /&gt;
			episodeNumber1, episodeNumber2 = mw.ustring.match(episodeNumber, &amp;#039;^(%w+)%s*[%s%-–/&amp;amp;]%s*(%w+)$&amp;#039;)&lt;br /&gt;
			divider = &amp;quot;–&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			episodeNumber1, episodeNumber2 = mw.ustring.match(episodeNumber, &amp;#039;^(%w+)%s*[%s%-–/&amp;amp;].-[%s%-–/&amp;amp;]%s*(%w+)$&amp;#039;)  -- 3 or more elements&lt;br /&gt;
			divider = &amp;quot;–&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if (not episodeNumber1) then&lt;br /&gt;
			return episodeNumber&lt;br /&gt;
		elseif (not episodeNumber2) then&lt;br /&gt;
			return string.match(episodeNumber, &amp;#039;%w+&amp;#039;)&lt;br /&gt;
		else&lt;br /&gt;
			return episodeNumber1 .. divider .. episodeNumber2&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create EpisodeNumber2 and EpisodeNumber3 cells.&lt;br /&gt;
local function _createEpisodeNumberCellSecondary(episodeValue, numberOfParameterGroups)&lt;br /&gt;
	if (episodeValue) then&lt;br /&gt;
		local episodeText = getEpisodeText(episodeValue)&lt;br /&gt;
&lt;br /&gt;
		if (nonNilParams == 0) then&lt;br /&gt;
			createTableRowEpisodeNumberHeader(episodeValue, numberOfParameterGroups, episodeText)&lt;br /&gt;
		else&lt;br /&gt;
			createTableData(episodeText, numberOfParameterGroups, nil)&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		nonNilParams = nonNilParams + 1&lt;br /&gt;
&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create seconday episode number cells.&lt;br /&gt;
local function createEpisodeNumberCellSecondary(args, numberOfParameterGroups)&lt;br /&gt;
	_createEpisodeNumberCellSecondary(args.EpisodeNumber2, numberOfParameterGroups)&lt;br /&gt;
	_createEpisodeNumberCellSecondary(args.EpisodeNumber3, numberOfParameterGroups)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create an EpisodeNumber cell.&lt;br /&gt;
local function createEpisodeNumberCell(args, numberOfParameterGroups)&lt;br /&gt;
	if (args.EpisodeNumber) then&lt;br /&gt;
		local episodeText = getEpisodeText(args.EpisodeNumber)&lt;br /&gt;
		createTableRowEpisodeNumberHeader(args.EpisodeNumber, numberOfParameterGroups, episodeText)&lt;br /&gt;
		nonNilParams = nonNilParams + 1&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create a single row of cells.&lt;br /&gt;
-- This is the standard function called.&lt;br /&gt;
local function createSingleRowCells(args, numberOfParameterGroups, multiTitleListEnabled, onInitialPage, title)&lt;br /&gt;
	createEpisodeNumberCell(args, 1)&lt;br /&gt;
	createEpisodeNumberCellSecondary(args, 1)&lt;br /&gt;
	createTitleCell(args, numberOfParameterGroups, multiTitleListEnabled, false)&lt;br /&gt;
	createCells(args, false, 1, onInitialPage, title, numberOfParameterGroups)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to create a multiple row of cells.&lt;br /&gt;
-- This function is called when part of the row is rowspaned.&lt;br /&gt;
-- Current use is for Doctor Who serials.&lt;br /&gt;
local function createMultiRowCells(args, numberOfParameterGroups, onInitialPage, title, topColor)&lt;br /&gt;
	createEpisodeNumberCell(args, numberOfParameterGroups)&lt;br /&gt;
	createEpisodeNumberCellSecondary(args, numberOfParameterGroups)&lt;br /&gt;
	createTitleCell(args, numberOfParameterGroups, false, true)&lt;br /&gt;
&lt;br /&gt;
	for i = 1, numberOfParameterGroups do&lt;br /&gt;
		args = extractDataFromNumberedSerialArgs(args, i, numberOfParameterGroups, title)&lt;br /&gt;
		createCells(args, true, i, onInitialPage, title, numberOfParameterGroups)&lt;br /&gt;
		if (i ~= numberOfParameterGroups) then&lt;br /&gt;
			row = row:done()  -- Use done() to close the &amp;#039;tr&amp;#039; tag in rowspaned rows.&lt;br /&gt;
				:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
				:addClass(&amp;#039;vevent&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;background&amp;#039;, topColor)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to retrieve the NumParts value.&lt;br /&gt;
local function getnumberOfParameterGroups(args)&lt;br /&gt;
	for k, v in ipairs(cellNameList) do&lt;br /&gt;
		local numberedParameter = v .. &amp;quot;_&amp;quot; .. 1&lt;br /&gt;
		if (args[numberedParameter]) then&lt;br /&gt;
			parameterGroupCells[v] = true&lt;br /&gt;
			if not firstParameterGroupCell then&lt;br /&gt;
				firstParameterGroupCell = k&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (hasValue(args.NumParts)) then&lt;br /&gt;
		return args.NumParts, true&lt;br /&gt;
	else&lt;br /&gt;
		return 1, false&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to retrieve the Top Color value.&lt;br /&gt;
local function getTopColor(args, rowColorEnabled, onInitialPage)&lt;br /&gt;
	local episodeNumber = mathModule._cleanNumber(args.EpisodeNumber) or 1&lt;br /&gt;
	if (args.TopColor) then&lt;br /&gt;
		if (string.find(args.TopColor, &amp;quot;#&amp;quot;)) then&lt;br /&gt;
			return args.TopColor&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;#039;#&amp;#039; .. args.TopColor&lt;br /&gt;
		end&lt;br /&gt;
	elseif (rowColorEnabled and onInitialPage and mathModule._mod(episodeNumber, 2) == 0) then&lt;br /&gt;
		return &amp;#039;#E9E9E9&amp;#039;&lt;br /&gt;
	elseif (onInitialPage and args.ShortSummary) then&lt;br /&gt;
		return &amp;#039;#F2F2F2&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;inherit&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to retrieve the Row Color value.&lt;br /&gt;
local function isRowColorEnabled(args)&lt;br /&gt;
	local rowColorEnabled = yesNoModule(args.RowColor, false)&lt;br /&gt;
&lt;br /&gt;
	if (args.RowColor and string.lower(args.RowColor) == &amp;#039;on&amp;#039;) then&lt;br /&gt;
		rowColorEnabled = true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return rowColorEnabled&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to retrieve the Line Color value.&lt;br /&gt;
local function getLineColor(args)&lt;br /&gt;
	-- Default color to light blue&lt;br /&gt;
	local lineColor = args.LineColor or &amp;#039;CCCCFF&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	-- Add # to color if necessary, and set to default color if invalid&lt;br /&gt;
	if (htmlColor[lineColor] == nil) then&lt;br /&gt;
		lineColor = &amp;#039;#&amp;#039; .. (mw.ustring.match(lineColor, &amp;#039;^[%s#]*([a-fA-F0-9]*)[%s]*$&amp;#039;) or &amp;#039;&amp;#039;)&lt;br /&gt;
		if (lineColor == &amp;#039;#&amp;#039;) then&lt;br /&gt;
			lineColor = &amp;#039;#CCCCFF&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return lineColor&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which is used to check if the table is located on the page&lt;br /&gt;
-- currently viewed, or on a transcluded page instead.&lt;br /&gt;
-- If it is on a transcluded page, the episode summary should not be shown.&lt;br /&gt;
local function isOnInitialPage(args, sublist, pageTitle, initiallistTitle)&lt;br /&gt;
	-- This should be the only check needed, however, it was previously implemented with two templates&lt;br /&gt;
	-- with one of them not requiring an article name, so for backward compatability, the whole sequence is kept.&lt;br /&gt;
	local onInitialPage&lt;br /&gt;
&lt;br /&gt;
	-- Only sublist had anything about hiding, so only it needs to even check&lt;br /&gt;
	if (sublist) then&lt;br /&gt;
		onInitialPage = mw.uri.anchorEncode(pageTitle) == mw.uri.anchorEncode(initiallistTitle)&lt;br /&gt;
		-- avoid processing ghost references&lt;br /&gt;
		if (not onInitialPage) then&lt;br /&gt;
			args.ShortSummary = nil&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		if (initiallistTitle == &amp;quot;&amp;quot;) then&lt;br /&gt;
			onInitialPage = true&lt;br /&gt;
		else&lt;br /&gt;
			onInitialPage = mw.uri.anchorEncode(pageTitle) == mw.uri.anchorEncode(initiallistTitle)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return onInitialPage&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which does the actual main process.&lt;br /&gt;
local function _main(args, sublist)&lt;br /&gt;
	local title = mw.title.getCurrentTitle()&lt;br /&gt;
	local pageTitle = title.text&lt;br /&gt;
	local initiallistTitle = args[&amp;#039;1&amp;#039;] or &amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	-- Is this list on the same page as the page directly calling the template?&lt;br /&gt;
	local onInitialPage = isOnInitialPage(args, sublist, pageTitle, initiallistTitle)&lt;br /&gt;
&lt;br /&gt;
	-- Need just this parameter removed if blank, no others&lt;br /&gt;
	if (hasValue(args.ShortSummary) == false) then&lt;br /&gt;
		args.ShortSummary = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local lineColor = getLineColor(args)&lt;br /&gt;
	local rowColorEnabled = isRowColorEnabled(args)&lt;br /&gt;
	local topColor = getTopColor(args, rowColorEnabled, onInitialPage)&lt;br /&gt;
&lt;br /&gt;
	local root = mw.html.create()							-- Create the root mw.html object to return&lt;br /&gt;
	row = root:tag(&amp;#039;tr&amp;#039;)									-- Create the table row and store it globally&lt;br /&gt;
				:addClass(&amp;#039;vevent&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;background&amp;#039;, topColor)&lt;br /&gt;
&lt;br /&gt;
	local numberOfParameterGroups, multiTitleListEnabled = getnumberOfParameterGroups(args)&lt;br /&gt;
&lt;br /&gt;
	if (multiTitleListEnabled and not args.Title_2) then&lt;br /&gt;
		createMultiRowCells(args, numberOfParameterGroups, onInitialPage, title, topColor)&lt;br /&gt;
	else&lt;br /&gt;
		createSingleRowCells(args, numberOfParameterGroups, multiTitleListEnabled, onInitialPage, title)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- add these categories only in the mainspace and only if they are on the page where the template is used&lt;br /&gt;
	if (onInitialPage and title.namespace == 0) then&lt;br /&gt;
		addLineColorTrackingCategories(args)&lt;br /&gt;
		addTopColorTrackingCategories(args)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (cellValueTBA == true and title.namespace == 0) then&lt;br /&gt;
		addTrackingCategory(trackingCategoryList[&amp;quot;tba_values&amp;quot;])&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Do not show the summary if this is being transcluded on the initial list page&lt;br /&gt;
	-- Do include it on all other lists&lt;br /&gt;
	if (onInitialPage and args.ShortSummary) then&lt;br /&gt;
		local bottomWrapper = createShortSummaryRow(args, lineColor)&lt;br /&gt;
		return tostring(root) .. tostring(bottomWrapper) .. trackingCategories&lt;br /&gt;
	else&lt;br /&gt;
		return tostring(root) .. trackingCategories&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function which handles both module entry points.&lt;br /&gt;
local function main(frame, sublist)&lt;br /&gt;
	-- Most parameters should still display when blank, so don&amp;#039;t remove blanks&lt;br /&gt;
	local args = require(&amp;#039;Module:Arguments&amp;#039;).getArgs(frame, {&lt;br /&gt;
		removeBlanks = false, &lt;br /&gt;
		wrappers = sublist and &amp;#039;Template:Episode list/sublist&amp;#039; or &amp;#039;Template:Episode list&amp;#039;})&lt;br /&gt;
&lt;br /&gt;
	-- args[&amp;#039;1&amp;#039;] = mw.getCurrentFrame():getParent():getTitle()&lt;br /&gt;
	return frame:extensionTag{&lt;br /&gt;
		name = &amp;#039;templatestyles&amp;#039;, args = { src = &amp;#039;Module:Episode list/styles.css&amp;#039; }&lt;br /&gt;
	} .. _main(args, sublist, frame)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Public function which is used to create an Episode row&lt;br /&gt;
for an Episode Table used for lists of episodes where each table is on a different page,&lt;br /&gt;
usually placed on individual season articles.&lt;br /&gt;
&lt;br /&gt;
For tables which are all on the same page see p.list().&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
	-- |1=					— required; The title of the article where the Episode Table is located at.&lt;br /&gt;
	-- |EpisodeNumber=		— suggested; The overall episode number in the series.&lt;br /&gt;
	-- |EpisodeNumber2=		— suggested; The episode number in the season.&lt;br /&gt;
	-- |Title=				— suggested; The English title of the episode.&lt;br /&gt;
	-- |RTitle=				— optional; Unformatted parameter that can be used to add a reference after &amp;quot;Title&amp;quot;,&lt;br /&gt;
											or can be used as a &amp;quot;raw title&amp;quot; to replace &amp;quot;Title&amp;quot; completely.&lt;br /&gt;
	-- |AltTitle=			— optional; An alternative title, such as the title of a foreign show&amp;#039;s episode in its native language,&lt;br /&gt;
											or a title that was originally changed.&lt;br /&gt;
	-- |TranslitTitle=		— optional; The title of the episode transliteration (Romanization) to Latin characters.&lt;br /&gt;
	-- |RAltTitle=			— optional; Unformatted parameter that can be used to add a reference after &amp;quot;AltTitle&amp;quot;,&lt;br /&gt;
											or can be used as a &amp;quot;raw title&amp;quot; to replace &amp;quot;AltTitle&amp;quot; completely.&lt;br /&gt;
	-- |NativeTitle=		— optional; The title of the episode in the native language.&lt;br /&gt;
	-- |NativeTitleLangCode — optional; The language code of the native title language.&lt;br /&gt;
	-- |Aux1=				— optional; General purpose parameter. The meaning is specified by the column header.&lt;br /&gt;
										This parameter is also used for Serial episode titles, such as those used in Doctor Who.&lt;br /&gt;
	-- |DirectedBy=			— optional; Name of the episode&amp;#039;s director. May contain links.&lt;br /&gt;
	-- |WrittenBy=			— optional; Primary writer(s) of the episode. May include links.&lt;br /&gt;
	-- |Aux2=				— optional; General purpose parameter. The meaning is specified by the column header.&lt;br /&gt;
	-- |Aux3=				— optional; General purpose parameter. The meaning is specified by the column header.&lt;br /&gt;
	-- |OriginalAirDate=	— optional; This is the date the episode first aired on TV, or is scheduled to air.&lt;br /&gt;
	-- |AltDate=			— optional; The next notable air date, such as the first air date of an anime in English.&lt;br /&gt;
	-- |Guests=             — optional; List of Guests for talk shows.  Cannot be used simultaneously with Aux1.&lt;br /&gt;
	-- |MusicalGuests=      — optional; List of MusicalGuests for talk shows.  Cannot be used simultaneously with Aux2. &lt;br /&gt;
	-- |ProdCode=			— optional; The production code in the series. When defined, this parameter also creates a link anchor,&lt;br /&gt;
											prefixed by &amp;quot;pc&amp;quot;; for example, List of episodes#pc01.&lt;br /&gt;
	-- |Viewers=			— optional; Number of viewers who watched the episode. Should include a reference.&lt;br /&gt;
	-- |Aux4=				— optional; General purpose parameter. The meaning is specified by the column header.&lt;br /&gt;
	-- |ShortSummary=		— optional; A short 100–200 word plot summary of the episode.&lt;br /&gt;
	-- |LineColor=			— optional; Colors the separator line between episode entries. If not defined the color defaults to &amp;quot;#CCCCFF&amp;quot;&lt;br /&gt;
											and the article is placed in Category:Episode list using the default LineColor.&lt;br /&gt;
											Use of &amp;quot;#&amp;quot;, or anything but a valid hex code will result in an invalid syntax.&lt;br /&gt;
	-- |TopColor=			— discouraged; Colors the main row of information (that is, not the ShortSummary row).&lt;br /&gt;
											Articles using this parameter are placed in Category:Episode lists with row deviations.&lt;br /&gt;
	-- |RowColor=			— optional; Switch parameter that must only be defined when the EpisodeNumber= entry is not a regular number&lt;br /&gt;
											(e.g. &amp;quot;12–13&amp;quot; for two episodes described in one table entry).&lt;br /&gt;
											If the first episode number is even, define pass &amp;quot;on&amp;quot;. If the first episode number is odd, pass &amp;quot;off&amp;quot;.&lt;br /&gt;
--]]&lt;br /&gt;
function p.sublist(frame)&lt;br /&gt;
	return main(frame, true)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Public function which is used to create an Episode row&lt;br /&gt;
for an Episode Table used for lists of episodes where all tables are on the same page.&lt;br /&gt;
&lt;br /&gt;
For tables which are on different pages see p.sublist().&lt;br /&gt;
&lt;br /&gt;
For complete parameter documentation, see the documentation at p.sublist().&lt;br /&gt;
--]]&lt;br /&gt;
function p.list(frame)&lt;br /&gt;
	return main(frame, false)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;GKFX</name></author>
	</entry>
</feed>