createTableData(args.ProdCode, 1, "")
else
-- ProductionCode parameter not used; Do nothing.
end  
nonNilParams = nonNilParams + 1
end  
---
Local function which is used to extract data
from the numbered serial parameters (Title1, Aux1, etc.), and then convert them to
use the non-numbered parameter names (Title, Aux).  
The function returns the args as non-numbered prameter names.
---
local function extractDataFromNumberedSerialArgs(args, i, numberOfParameterGroups, title)
for _, v in ipairs(cellNameList) do
local parameter = v
local numberedParameter = v .. "_" .. i
local excludeParameter = excludeList[parameter] or 'NULL' .. parameter
local excludeNumberParameter = (excludeList[numberedParameter] or 'NULL' .. parameter) .. "_" .. i
if (not hasValue(args[numberedParameter]) and not hasValue(args[excludeNumberParameter])
and hasValue(parameterGroupCells[parameter]) and not hasValue(args[excludeParameter])) then
if (v ~= 'ProdCode') then
createEmptyCell(args, parameter, true)
else
args[parameter] = ''
end
if (title.namespace == 0) then
addTrackingCategory(trackingCategoryList["nonmatching_numbered_parameters"])
end
elseif (hasValue(args[numberedParameter]) and not hasValue(args[excludeNumberParameter])) then
args[parameter] = args[numberedParameter]
end
end  
return args
end  
---
Local function which is used to create column cells.  
EpisodeNumber, EpisodeNumber2 and Title are created in different functions
as they require some various if checks.  
See:
-- createEpisodeNumberCell
-- createEpisodeNumberCellSecondary
-- createTitleCell
---
local function createCells(args, isSerial, currentRow, onInitialPage, title, numberOfParameterGroups)
for k, v in ipairs(cellNameList) do
if (v == 'ProdCode') then
createProductionCodeCell(args, v)
elseif (args[v]) then
-- Set empty cells to TBA/TBD
if (args[v] == '') then
createEmptyCell(args, v, false)
elseif (v == 'WrittenBy' and title.namespace == 0) then
if ((string.find(args[v], "*Story") ~= nil or string.find(args[v], "*Teleplay") ~= nil) and string.find(args[v], "8202") == nil) then
-- &#8202; is the hairspace added through
addTrackingCategory(trackingCategoryList["raw_unformatted_storyteleplay"])
end
end  
-- If serial titles need to be centered and not , then this should be removed.
local text
if (v == 'Aux1' and isSerial) then
text
end  
-- Remove wikilinks from links in serial rowspans rows after the first.
-- if (currentRow > 1) then
-- args[v] = removeWikilinks(args, v)
-- end  
local thisRowspan
if (firstParameterGroupCell and k < firstParameterGroupCell) then
thisRowspan = numberOfParameterGroups
else
thisRowspan = 1
end  
if (currentRow == 1 or (currentRow > 1 and k >= (firstParameterGroupCell or 0))) then
createTableData(args[v], thisRowspan, textAlign)
end
nonNilParams = nonNilParams + 1
checkUsageOfDateTemplates(args, v, onInitialPage, title)
end  
if (args[v] == "TBA") then
cellValueTBA = true
end
end
end  
---
Local function which is used to create the Title cell text.  
The title text will be handled in the following way:
Line 1: <Title><RTitle> (with no space between)
Line 2: <AltTitle><RAltTitle> (with no space between) OR
Line 2: Transcription: <TranslitTitle> (<Language>: <NativeTitle>)<RAltTitle> (with space between first two parameters)  
If <Title> or <RTitle> are empty,
then the values of line 2 will be placed on line 1 instead.  
---
local function createTitleText(args)
local titleString = ''
local isCellPresent = false
local useSecondLine = false
local lineBreakUsed = false  
-- Surround the Title with quotes; No quotes if empty.
if (args.Title ~= nil) then
if (args.Title == "") then
isCellPresent = true
else
titleString = '"' .. args.Title .. '"'
useSecondLine = true
isCellPresent = true
end
end  
if (args.RTitle ~= nil) then
if (args.RTitle == "") then
isCellPresent = true
else
titleString = titleString .. args.RTitle
useSecondLine = true
isCellPresent = true
end
end  
-- Surround the AltTitle/TranslitTitle with quotes; No quotes if empty.
if (args.AltTitle or args.TranslitTitle) then  
isCellPresent = true  
if (useSecondLine) then
titleString = titleString .. "
"
lineBreakUsed = true
end  
if (hasValue(args.AltTitle)) then
titleString = titleString .. '"' .. args.AltTitle .. '"'
elseif (hasValue(args.TranslitTitle)) then
if (hasValue(args.NativeTitleLangCode)) then
titleString = titleString .. 'Transcription: "' .. langModule._transl({args.NativeTitleLangCode, args.TranslitTitle, italic = 'no'}) .. '"'
else
titleString = titleString .. 'Transcription: "' .. args.TranslitTitle .. '"'
end
end
end  
if (args.NativeTitle ~= nil) then
if (args.NativeTitle == "") then
isCellPresent = true
else
isCellPresent = true  
if (useSecondLine and lineBreakUsed == false) then
titleString = titleString .. "
"
end  
if (hasValue(args.NativeTitleLangCode)) then
local languageCode = "Lang-" .. args.NativeTitleLangCode
titleString = titleString .. " (" .. langModule._lang_xx_inherit({code = args.NativeTitleLangCode, args.NativeTitle}) .. ")"
else
titleString = titleString .. " (" .. args.NativeTitle .. ")"
end
end
end  
if (args.RAltTitle ~= nil) then
if (args.RAltTitle == "") then
isCellPresent = true
else
isCellPresent = true  
if (useSecondLine and lineBreakUsed == false) then
titleString = titleString .. "
"
end  
titleString = titleString .. args.RAltTitle
end
end  
return titleString, isCellPresent
end  
---
Local function which is used to extract data
from the numbered title parameters (Title1, RTitle2, etc.), and then convert them to
use the non-numbered prameter names (Title, RTitle).  
The function returns two results:
-- The args parameter table.
-- A boolean indicating if the title group has data.
---
local function extractDataFromNumberedTitleArgs(args, i)
local nextGroupValid = false  
for _, v in ipairs(titleList) do
local parameter = v
local numberedParameter = v .. "_" .. i
args[parameter] = args[numberedParameter]  
if (nextGroupValid == false and hasValue(args[numberedParameter])) then
nextGroupValid = true
end
end  
return args, nextGroupValid
end  
-- Local function which is used to process the multi title list.
local function processMultiTitleList(args, numberOfParameterGroups)
local nativeTitleLangCode = args.NativeTitleLangCode
local titleText = ""
local isCellPresent = false
local isFirstTitleGroup = true -- Making sure that the title cell is created at least once and isn't created again if other #N titles are empty.  
for i = 1, numberOfParameterGroups do
local args, nextGroupValid = extractDataFromNumberedTitleArgs(args, i)
if (nextGroupValid) then
if (isFirstTitleGroup == false) then
titleText = titleText .. "<hr />"
end  
local titleTextRow
titleTextRow = createTitleText(args)
titleText = titleText .. titleTextRow
isFirstTitleGroup = false
else
if (isFirstTitleGroup) then
titleText, isCellPresent = createTitleText(args)
end  
-- Valid titles have to be in succession (#1, #2, #3 and not #1, #4 #5), so exit for loop if next group is empty.
return titleText, isCellPresent
end
end  
return titleText
end  
-- Local function which is used to create a Title cell.
local function createTitleCell(args, numberOfParameterGroups, multiTitleListEnabled, isSerial)
local titleText
local isCellPresent  
if (multiTitleListEnabled) then
titleText, isCellPresent = processMultiTitleList(args, numberOfParameterGroups)
else
titleText, isCellPresent = createTitleText(args)
end  
if (isCellPresent == false) then
return nil
end  
local text  
-- If Title is blank, then set Raw Title to TBA
if (hasValue(titleText) == false) then
titleText = tableEmptyCellModule._main({})
text
end  
-- If title is the first cell, create it with a !scope="row"
if (nonNilParams == 0) then
if (isSerial) then
row:tag('th')
:addClass('summary')
:attr('scope', 'row')
:attr('rowspan', numberOfParameterGroups)
:css('text-align', textAlign)
:wikitext(titleText)
else
row:tag('th')
:addClass('summary')
:attr('scope', 'row')
:css('text-align', textAlign)
:wikitext(titleText)
end
else
if (isSerial) then
row:tag('td')