<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.randombell.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATelevision_episode_short_description</id>
	<title>Module:Television episode short description - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.randombell.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATelevision_episode_short_description"/>
	<link rel="alternate" type="text/html" href="https://wiki.randombell.com/index.php?title=Module:Television_episode_short_description&amp;action=history"/>
	<updated>2026-04-17T10:21:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://wiki.randombell.com/index.php?title=Module:Television_episode_short_description&amp;diff=1633&amp;oldid=prev</id>
		<title>Randombell: Created page with &quot;--- @module local television = {}  -- Unique suffix list. local uniqueSuffix = { 	[1] = &quot;st&quot;, 	[2] = &quot;nd&quot;, 	[3] = &quot;rd&quot;, }  -- Common suffix. local commonSuffix = &quot;th&quot;  -- Test validation. local test = false  local descriptions = { 	no_series = { 		type = 1, 		text = &quot;Television episode&quot;, 		category = &quot;%s&quot;, 	}, 	only_series_name = { 		type = 2, 		text = &quot;Episode of %s&quot;, 		category = &quot;[[Cat...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.randombell.com/index.php?title=Module:Television_episode_short_description&amp;diff=1633&amp;oldid=prev"/>
		<updated>2025-08-19T15:15:10Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--- @module local television = {}  -- Unique suffix list. local uniqueSuffix = { 	[1] = &amp;quot;st&amp;quot;, 	[2] = &amp;quot;nd&amp;quot;, 	[3] = &amp;quot;rd&amp;quot;, }  -- Common suffix. local commonSuffix = &amp;quot;th&amp;quot;  -- Test validation. local test = false  local descriptions = { 	no_series = { 		type = 1, 		text = &amp;quot;Television episode&amp;quot;, 		category = &amp;quot;&lt;a href=&quot;/index.php?title=Category:Television_episode_articles_with_short_description_with_no_series_name&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Television episode articles with short description with no series name (page does not exist)&quot;&gt;%s&lt;/a&gt;&amp;quot;, 	}, 	only_series_name = { 		type = 2, 		text = &amp;quot;Episode of %s&amp;quot;, 		category = &amp;quot;[[Cat...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--- @module&lt;br /&gt;
local television = {}&lt;br /&gt;
&lt;br /&gt;
-- Unique suffix list.&lt;br /&gt;
local uniqueSuffix = {&lt;br /&gt;
	[1] = &amp;quot;st&amp;quot;,&lt;br /&gt;
	[2] = &amp;quot;nd&amp;quot;,&lt;br /&gt;
	[3] = &amp;quot;rd&amp;quot;,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Common suffix.&lt;br /&gt;
local commonSuffix = &amp;quot;th&amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- Test validation.&lt;br /&gt;
local test = false&lt;br /&gt;
&lt;br /&gt;
local descriptions = {&lt;br /&gt;
	no_series = {&lt;br /&gt;
		type = 1,&lt;br /&gt;
		text = &amp;quot;Television episode&amp;quot;,&lt;br /&gt;
		category = &amp;quot;[[Category:Television episode articles with short description with no series name|%s]]&amp;quot;,&lt;br /&gt;
	},&lt;br /&gt;
	only_series_name = {&lt;br /&gt;
		type = 2,&lt;br /&gt;
		text = &amp;quot;Episode of %s&amp;quot;,&lt;br /&gt;
		category = &amp;quot;[[Category:Television episode articles with short description with no season number|%s]]&amp;quot;,&lt;br /&gt;
	},&lt;br /&gt;
	season_and_series_name = {&lt;br /&gt;
		type = 3,&lt;br /&gt;
		text = &amp;quot;Episode of the %s %s of %s&amp;quot;,&lt;br /&gt;
		category = &amp;quot;[[Category:Television episode articles with short description with no episode number|%s]]&amp;quot;,&lt;br /&gt;
	},&lt;br /&gt;
	single_episode = {&lt;br /&gt;
		type = 4,&lt;br /&gt;
		text = &amp;quot;%s episode of the %s %s of %s&amp;quot;,&lt;br /&gt;
		category = &amp;quot;[[Category:Television episode articles with short description for single episodes|%s]]&amp;quot;,&lt;br /&gt;
	},&lt;br /&gt;
	multi_episodes = {&lt;br /&gt;
		type = 5,&lt;br /&gt;
		text = &amp;quot;%s episodes of the %s %s of %s&amp;quot;,&lt;br /&gt;
		category = &amp;quot;[[Category:Television episode articles with short description for multi-part episodes|%s]]&amp;quot;,&lt;br /&gt;
	},&lt;br /&gt;
	limited_series = {&lt;br /&gt;
		type = 6,&lt;br /&gt;
		text = {&lt;br /&gt;
			single_episode = &amp;quot;%s episode of %s&amp;quot;,&lt;br /&gt;
			multi_episodes = &amp;quot;%s episodes of %s&amp;quot;,&lt;br /&gt;
		},&lt;br /&gt;
		category = &amp;quot;&amp;quot;, -- None&lt;br /&gt;
	},&lt;br /&gt;
	special_episode = {&lt;br /&gt;
		type = 7,&lt;br /&gt;
		text = &amp;quot;%s episode of %s&amp;quot;,&lt;br /&gt;
		category = &amp;quot;&amp;quot;, -- None&lt;br /&gt;
	},&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Tracking category list.&lt;br /&gt;
local trackingCategories = {&lt;br /&gt;
	disambiguated = &amp;quot;[[Category:Television episode articles with short description and disambiguated page names|%s]]&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--- Returns a tracking category from a list by its name and adds a sort key.&lt;br /&gt;
--- @param typeName string The name of the category type.&lt;br /&gt;
--- @param useTrackingList boolean Whether to return a category from the trackingCategories list.&lt;br /&gt;
--- @param sortKey string The key by which to sort the page in the category.&lt;br /&gt;
local function getTrackingCategoryFromList(typeName, useTrackingList, sortKey)&lt;br /&gt;
	local category&lt;br /&gt;
	if useTrackingList then&lt;br /&gt;
		category = trackingCategories[typeName]&lt;br /&gt;
	else&lt;br /&gt;
		category = descriptions[typeName].category&lt;br /&gt;
	end&lt;br /&gt;
	return string.format(category, sortKey)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns true if the article name is disambiguated.&lt;br /&gt;
---&lt;br /&gt;
--- This is usually in the format of &amp;quot;Episode name (&amp;lt;TV series name&amp;gt;)&amp;quot; or &amp;quot;Episode name (&amp;lt;TV series name&amp;gt; episode)&amp;quot;.&lt;br /&gt;
--- @param articleTitle string The name of the page.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
local function isDisambiguated(articleTitle, tvSeriesName)&lt;br /&gt;
	local disambiguation = string.match(tostring(articleTitle), &amp;quot;%s%((.-)%)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	if not (disambiguation and tvSeriesName) then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Search for the TV series name in the article name disambiguation.&lt;br /&gt;
	if (string.find(disambiguation, tvSeriesName)) then&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the sort key for the current page.&lt;br /&gt;
local function getSortKey()&lt;br /&gt;
	local sortTitleModule = require(&amp;quot;Module:Sort title&amp;quot;)&lt;br /&gt;
	return sortTitleModule._getSortKey()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a tracking category depending on the type of short description created.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param descriptionName string&lt;br /&gt;
local function getTrackingCategory(tvSeriesName, descriptionName)&lt;br /&gt;
	local articleTitle = mw.title.getCurrentTitle()&lt;br /&gt;
	local namespace = articleTitle.nsText&lt;br /&gt;
&lt;br /&gt;
	-- Check if the invoking page is from the allowed namespace.&lt;br /&gt;
	if (not (namespace == &amp;quot;&amp;quot; or namespace == &amp;quot;Draft&amp;quot; or test)) then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local sortKey = getSortKey()&lt;br /&gt;
	if (isDisambiguated(articleTitle, tvSeriesName) == true) then&lt;br /&gt;
		local category1 = getTrackingCategoryFromList(descriptionName, false, sortKey)&lt;br /&gt;
		local category2 = getTrackingCategoryFromList(&amp;quot;disambiguated&amp;quot;, true, sortKey)&lt;br /&gt;
		return category1 .. category2&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return getTrackingCategoryFromList(descriptionName, false, sortKey)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Returns a short description in the style of: &amp;quot;Television episode&amp;quot; and a maintenance category:&lt;br /&gt;
--- &amp;quot;Category:Television episode articles with short description with no series name&amp;quot;.&lt;br /&gt;
local function getShortDescriptionNoSeries()&lt;br /&gt;
	local shortDescription = descriptions.no_series.text&lt;br /&gt;
	local category = getTrackingCategory(nil, &amp;quot;no_series&amp;quot;)&lt;br /&gt;
	return shortDescription, category&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a short description in the style of: &amp;quot;Episode of Lost&amp;quot; and a maintenance category:&lt;br /&gt;
--- &amp;quot;Category:Television episode articles with short description with no season number&amp;quot;.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
local function getShortDescriptionOnlySeriesName(tvSeriesName)&lt;br /&gt;
	local text = descriptions.only_series_name.text&lt;br /&gt;
	local shortDescription = string.format(text, tvSeriesName)&lt;br /&gt;
	local category = getTrackingCategory(tvSeriesName, &amp;quot;only_series_name&amp;quot;)&lt;br /&gt;
	return shortDescription, category&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a short description in the style of: &amp;quot;Episode of the first season of Lost&amp;quot; and a maintenance category:&lt;br /&gt;
--- &amp;quot;Category:Television episode articles with short description with no episode number&amp;quot;.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param seasonOrdinalNumber string The season&amp;#039;s ordinal number.&lt;br /&gt;
--- @param seasonTextStyle string The text to use for seasons - either &amp;quot;season&amp;quot; or &amp;quot;series&amp;quot;.&lt;br /&gt;
local function getShortDescriptionSeasonAndSeriesName(tvSeriesName, seasonOrdinalNumber, seasonTextStyle)&lt;br /&gt;
	local text = descriptions.season_and_series_name.text&lt;br /&gt;
	local shortDescription = string.format(text, seasonOrdinalNumber, seasonTextStyle, tvSeriesName)&lt;br /&gt;
	local category = getTrackingCategory(tvSeriesName, &amp;quot;season_and_series_name&amp;quot;)&lt;br /&gt;
	return shortDescription, category&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a short description for a limited series in the style of: &amp;quot;1st episode of WandaVision&amp;quot; and a tracking category&lt;br /&gt;
--- based on the categoryKey value.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param episodeOrdinalNumber string The episode&amp;#039;s ordinal number.&lt;br /&gt;
--- @param descriptionName string A key from the descriptions table.&lt;br /&gt;
local function getShortDescriptionLimitedSeries(tvSeriesName, episodeOrdinalNumber, descriptionName)&lt;br /&gt;
	local text = descriptions.limited_series.text[descriptionName]&lt;br /&gt;
	local shortDescription = string.format(text, episodeOrdinalNumber, tvSeriesName)&lt;br /&gt;
	local category = getTrackingCategory(tvSeriesName, descriptionName)&lt;br /&gt;
	return shortDescription, category&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a short description in the style of: &amp;quot;5th episode of the fourth season of Lost&amp;quot; and a tracking category:&lt;br /&gt;
--- &amp;quot;Category:Television episode articles with short description for single episodes&amp;quot;.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param seasonOrdinalNumber string The season&amp;#039;s ordinal number.&lt;br /&gt;
--- @param seasonTextStyle string The text to use for seasons - either &amp;quot;season&amp;quot; or &amp;quot;series&amp;quot;.&lt;br /&gt;
--- @param episodeOrdinalNumber string The episode&amp;#039;s ordinal number.&lt;br /&gt;
--- @param limitedSeries boolean Whether the episode belongs to a limited series.&lt;br /&gt;
local function getShortDescriptionSingleEpisode(tvSeriesName, seasonOrdinalNumber, seasonTextStyle, episodeOrdinalNumber, limitedSeries)&lt;br /&gt;
	if (limitedSeries) then&lt;br /&gt;
		return getShortDescriptionLimitedSeries(tvSeriesName, episodeOrdinalNumber,&amp;quot;single_episode&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local text = descriptions.single_episode.text&lt;br /&gt;
	local shortDescription =  string.format(text, episodeOrdinalNumber, seasonOrdinalNumber, seasonTextStyle, tvSeriesName)&lt;br /&gt;
	local category = getTrackingCategory(tvSeriesName, &amp;quot;single_episode&amp;quot;)&lt;br /&gt;
	return shortDescription, category&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a short description for a multi-part episode in the style of:&lt;br /&gt;
--- &amp;quot;23rd and 24th episodes of the third season of Lost&amp;quot; and a tracking category:&lt;br /&gt;
--- &amp;quot;Category:Television episode articles with short description for multi-part episodes&amp;quot;.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param seasonOrdinalNumber string The season&amp;#039;s ordinal number.&lt;br /&gt;
--- @param seasonTextStyle string The text to use for seasons - either &amp;quot;season&amp;quot; or &amp;quot;series&amp;quot;.&lt;br /&gt;
--- @param episodeOrdinalNumbers table A list of episode ordinal numbers.&lt;br /&gt;
--- @param limitedSeries boolean Whether the episode belongs to a limited series.&lt;br /&gt;
local function getShortDescriptionMultiEpisode(tvSeriesName, seasonOrdinalNumber, seasonTextStyle, episodeOrdinalNumbers, limitedSeries)&lt;br /&gt;
	local episodeText = mw.text.listToText(episodeOrdinalNumbers)&lt;br /&gt;
&lt;br /&gt;
	if (limitedSeries) then&lt;br /&gt;
		return getShortDescriptionLimitedSeries(tvSeriesName, episodeText, &amp;quot;multi_episodes&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local text = descriptions.multi_episodes.text&lt;br /&gt;
	local shortDescription = string.format(text, episodeText, seasonOrdinalNumber, seasonTextStyle, tvSeriesName)&lt;br /&gt;
	local category = getTrackingCategory(tvSeriesName, &amp;quot;multi_episodes&amp;quot;)&lt;br /&gt;
	return shortDescription, category&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a short description for a special episode in the style of:&lt;br /&gt;
--- &amp;quot;Special episode of Lost&amp;quot; or &amp;quot;&amp;lt;value&amp;gt; episode of Lost&amp;quot; and a tracking category:&lt;br /&gt;
--- &amp;quot;Category:Television episode articles with short description for single episodes&amp;quot;.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param special string The type of special episode. A &amp;quot;yes&amp;quot; value defaults to &amp;quot;Special&amp;quot;.&lt;br /&gt;
local function getShortDescriptionSpecialEpisode(tvSeriesName, special)&lt;br /&gt;
	if (special == &amp;quot;yes&amp;quot; or special == &amp;quot;y&amp;quot;) then&lt;br /&gt;
		special = &amp;quot;Special&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	local text = descriptions.special_episode.text&lt;br /&gt;
	local shortDescription = string.format(text, special, tvSeriesName)&lt;br /&gt;
	local category = getTrackingCategory(tvSeriesName, &amp;quot;single_episode&amp;quot;)&lt;br /&gt;
	return shortDescription, category&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a short description based on the description type passed.&lt;br /&gt;
--- @param descriptionType number A description type number.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param seasonOrdinalNumber string The season&amp;#039;s ordinal number.&lt;br /&gt;
--- @param seasonTextStyle string The text to use for seasons - either &amp;quot;season&amp;quot; or &amp;quot;series&amp;quot;.&lt;br /&gt;
--- @param episodeOrdinalNumbers table A list of episode ordinal numbers.&lt;br /&gt;
--- @param specialEpisode string The type of special episode.&lt;br /&gt;
--- @param limitedSeries boolean Whether the episode belongs to a limited series.&lt;br /&gt;
local function getShortDescriptionByType(&lt;br /&gt;
		descriptionType, tvSeriesName, seasonOrdinalNumber, seasonTextStyle, episodeOrdinalNumbers, specialEpisode, limitedSeries)&lt;br /&gt;
	if descriptionType == descriptions.no_series.type then&lt;br /&gt;
		return getShortDescriptionNoSeries()&lt;br /&gt;
	elseif descriptionType == descriptions.only_series_name.type then&lt;br /&gt;
		return getShortDescriptionOnlySeriesName(tvSeriesName)&lt;br /&gt;
	elseif descriptionType == descriptions.season_and_series_name.type then&lt;br /&gt;
		return getShortDescriptionSeasonAndSeriesName(tvSeriesName, seasonOrdinalNumber, seasonTextStyle)&lt;br /&gt;
	elseif descriptionType == descriptions.single_episode.type then&lt;br /&gt;
		return getShortDescriptionSingleEpisode(&lt;br /&gt;
                tvSeriesName, seasonOrdinalNumber, seasonTextStyle, episodeOrdinalNumbers[1], limitedSeries)&lt;br /&gt;
	elseif descriptionType == descriptions.multi_episodes.type then&lt;br /&gt;
		return getShortDescriptionMultiEpisode(&lt;br /&gt;
				tvSeriesName, seasonOrdinalNumber, seasonTextStyle, episodeOrdinalNumbers, limitedSeries)&lt;br /&gt;
	elseif descriptionType == descriptions.special_episode.type then&lt;br /&gt;
		return getShortDescriptionSpecialEpisode(tvSeriesName, specialEpisode)&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the type of the description to use.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param seasonOrdinalNumber string The season&amp;#039;s ordinal number.&lt;br /&gt;
--- @param episodeOrdinalNumbers table A list of episode ordinal numbers.&lt;br /&gt;
--- @param specialEpisode string The type of special episode.&lt;br /&gt;
--- @param limitedSeries boolean Whether the episode belongs to a limited series.&lt;br /&gt;
local function getDescriptionType(tvSeriesName, seasonOrdinalNumber, episodeOrdinalNumbers, specialEpisode, limitedSeries)&lt;br /&gt;
	if (not tvSeriesName) then&lt;br /&gt;
		return descriptions.no_series.type&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (specialEpisode) then&lt;br /&gt;
		return descriptions.special_episode.type&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (not seasonOrdinalNumber and not limitedSeries) then&lt;br /&gt;
		return descriptions.only_series_name.type&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (#episodeOrdinalNumbers &amp;lt; 1) then&lt;br /&gt;
		return descriptions.season_and_series_name.type&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (#episodeOrdinalNumbers == 1) then&lt;br /&gt;
		return descriptions.single_episode.type&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if (#episodeOrdinalNumbers &amp;gt; 1) then&lt;br /&gt;
		return descriptions.multi_episodes.type&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns true if the TV series is a limited series.&lt;br /&gt;
--- @param limitedSeries string Any value will be considered as true.&lt;br /&gt;
--- @param tvSeriesNameDab string The disambiguation used in the series name article title.&lt;br /&gt;
local function isLimitedSeries(limitedSeries, tvSeriesNameDab)&lt;br /&gt;
	if (limitedSeries) then&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if tvSeriesNameDab and string.find(tvSeriesNameDab, &amp;quot;miniseries&amp;quot;) then&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the ordinal indicator for an integer between 0 and 100.&lt;br /&gt;
---&lt;br /&gt;
--- Numbers &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot; and &amp;quot;3&amp;quot; have unique suffixes.&lt;br /&gt;
--- Numbers between 4 and 20 have the same common suffix - &amp;quot;th&amp;quot;.&lt;br /&gt;
--- Numbers ending with 0 have the same common suffix - &amp;quot;th&amp;quot;.&lt;br /&gt;
--- @param number number A number value.&lt;br /&gt;
local function getOrdinalIndicatorLessThan100(number)&lt;br /&gt;
	local suffix&lt;br /&gt;
	while (not suffix) do&lt;br /&gt;
		-- Check if the number equals 0; This should never be a valid entry. Assign suffix as an empty string.&lt;br /&gt;
		if (number == 0) then&lt;br /&gt;
			suffix = &amp;quot;&amp;quot;&lt;br /&gt;
		-- Check if the number is less than 4; Numbers &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot; and &amp;quot;3&amp;quot; have unique suffixes.&lt;br /&gt;
		elseif (number &amp;lt; 4) then&lt;br /&gt;
			suffix = uniqueSuffix[number]&lt;br /&gt;
		-- Check if the number is more than 4 AND less than 20; These numbers all have the same common suffix.&lt;br /&gt;
		elseif (number &amp;lt; 20) then&lt;br /&gt;
			suffix = commonSuffix&lt;br /&gt;
		-- Check if the remainder after division of the number by 10 equals 0.&lt;br /&gt;
		elseif (number % 10 == 0) then&lt;br /&gt;
			suffix = commonSuffix&lt;br /&gt;
		else&lt;br /&gt;
			-- Numbers that are above 20 and which their remainder doesn&amp;#039;t equal 0 (such as 45).&lt;br /&gt;
			-- Remainder after division of the number by 10; So if the current number is 45, the new number is 5.&lt;br /&gt;
			number = number % 10&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return suffix&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the ordinal indicator for an integer between 0 and 1000.&lt;br /&gt;
--- @param number number A number value.&lt;br /&gt;
local function getOrdinalIndicatorLessThan1000(number)&lt;br /&gt;
	if (number &amp;lt; 100) then&lt;br /&gt;
		return getOrdinalIndicatorLessThan100(number)&lt;br /&gt;
	elseif (number % 100 == 0) then&lt;br /&gt;
		return commonSuffix&lt;br /&gt;
	else&lt;br /&gt;
		-- Numbers that are above 100 and which their remainder doesn&amp;#039;t equal 0 (such as 345).&lt;br /&gt;
		-- Pass the remainder after division of the number by 100 (So for 345, it would pass 45) as the parameter.&lt;br /&gt;
		return getOrdinalIndicatorLessThan100(number % 100)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a table of episode numbers.&lt;br /&gt;
---&lt;br /&gt;
--- Episode values may be of multipart episodes, in such situations, an episode may be seperated by one of the following:&lt;br /&gt;
--- &amp;quot;,&amp;quot;, &amp;quot;/&amp;quot;, &amp;quot;&amp;amp;&amp;quot;, &amp;quot;-&amp;quot;, &amp;quot;–&amp;quot;, &amp;quot;and&amp;quot;.&lt;br /&gt;
--- Decimal values and episode overall values sometimes erroneously used are removed.&lt;br /&gt;
--- @param number string A number value in string format.&lt;br /&gt;
local function cleanEpisodeNumber(number)&lt;br /&gt;
	if (not number) then&lt;br /&gt;
		return {}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	number = string.gsub(number, &amp;quot;%(.*%)&amp;quot;, &amp;quot; &amp;quot;)&lt;br /&gt;
	number = string.gsub(number, &amp;quot;%.%d+&amp;quot;, &amp;quot; &amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	local numbers = {}&lt;br /&gt;
	for digits in string.gmatch(number, &amp;quot;%d+&amp;quot;) do&lt;br /&gt;
		table.insert(numbers, tonumber(digits))&lt;br /&gt;
	end&lt;br /&gt;
	return numbers&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a table of episode ordinal numbers.&lt;br /&gt;
---&lt;br /&gt;
--- In most situations there will be only one episode, but this can support more.&lt;br /&gt;
--- @param episodeNumber number The episode&amp;#039;s number.&lt;br /&gt;
local function getEpisodeOrdinalNumbers(episodeNumber)&lt;br /&gt;
	local episodeNumbers = cleanEpisodeNumber(episodeNumber)&lt;br /&gt;
&lt;br /&gt;
	if (#episodeNumbers &amp;lt; 1) then&lt;br /&gt;
		return episodeNumbers&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local episodeOrdinals = {}&lt;br /&gt;
	for _, cleanedEpisodeNumber in pairs(episodeNumbers) do&lt;br /&gt;
		local ordinalIndicator = getOrdinalIndicatorLessThan1000(cleanedEpisodeNumber)&lt;br /&gt;
		table.insert(episodeOrdinals, cleanedEpisodeNumber .. ordinalIndicator)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return episodeOrdinals&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns true if the season number value is a number.&lt;br /&gt;
--- @param seasonNumber string The season number value in string format.&lt;br /&gt;
local function validateSeasonNumber(seasonNumber)&lt;br /&gt;
	if (tonumber(seasonNumber)) 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;
--- Returns the season&amp;#039;s ordinal number, or nil if no season number was set.&lt;br /&gt;
--- @param seasonNumber string The season number.&lt;br /&gt;
local function getSeasonOrdinalNumber(seasonNumber)&lt;br /&gt;
	if (seasonNumber) then&lt;br /&gt;
		local convertOrdinal = require(&amp;quot;Module:Ordinal&amp;quot;)&lt;br /&gt;
		return convertOrdinal._ordinal(seasonNumber)&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns a season number after removing from it unwanted characters.&lt;br /&gt;
---&lt;br /&gt;
--- This is done to make sure that no malformed season values have been entered.&lt;br /&gt;
--- The function will remove all text which is not part of the first number in the string.&lt;br /&gt;
---&lt;br /&gt;
--- The function converts entries such as:&lt;br /&gt;
--- &amp;quot;1.2&amp;quot; -&amp;gt; &amp;quot;1&amp;quot;&lt;br /&gt;
--- &amp;quot;12.2&amp;quot; -&amp;gt; &amp;quot;12&amp;quot;&lt;br /&gt;
--- @param seasonNumber string The season number value in string format.&lt;br /&gt;
local function cleanSeasonNumber(seasonNumber)&lt;br /&gt;
	if (seasonNumber) then&lt;br /&gt;
		return string.match(seasonNumber, &amp;quot;%d+&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the season number after or cleaning it from unwanted values and validating value is a number.&lt;br /&gt;
--- Also returns the text style to use - either &amp;quot;season&amp;quot; or &amp;quot;series&amp;quot;.&lt;br /&gt;
--- If no value was entered or if value was not a number, return nil.&lt;br /&gt;
--- @param seasonNumber string The season number.&lt;br /&gt;
--- @param seasonNumberUK string The season number, if UK style was used.&lt;br /&gt;
local function getSeasonNumberAndTextStyle(seasonNumber, seasonNumberUK)&lt;br /&gt;
    for _, v in ipairs({{seasonNumber, &amp;quot;season&amp;quot;}, {seasonNumberUK, &amp;quot;series&amp;quot;}}) do&lt;br /&gt;
        local cleanedSeasonNumber = cleanSeasonNumber(v[1])&lt;br /&gt;
        if (validateSeasonNumber(cleanedSeasonNumber)) then&lt;br /&gt;
            return cleanedSeasonNumber, v[2]&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the TV series title without disambiguation, and the disambiguation, or nil if no TV series name was set.&lt;br /&gt;
--- @param tvSeriesName string The TV series name.&lt;br /&gt;
--- @param notDab string If set, the parenthesis in the title is not disambiguation.&lt;br /&gt;
local function getTVSeriesName(tvSeriesName, notDab)&lt;br /&gt;
	if (tvSeriesName) then&lt;br /&gt;
		if (not notDab) then&lt;br /&gt;
			local title, disambiguation = string.match(tvSeriesName, &amp;quot;^(.+) %((.*)%)$&amp;quot;)&lt;br /&gt;
			if not title then&lt;br /&gt;
				title = tvSeriesName&lt;br /&gt;
			end&lt;br /&gt;
			return title, disambiguation&lt;br /&gt;
		end&lt;br /&gt;
		return tvSeriesName, nil&lt;br /&gt;
	end&lt;br /&gt;
	return nil, nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Returns the initial values after removing unwanted characters.&lt;br /&gt;
--- @param args table The values that should be processed.&lt;br /&gt;
local function cleanValues(args)&lt;br /&gt;
	for i, v in ipairs({&amp;quot;episode_num&amp;quot;, &amp;quot;season_num&amp;quot;, &amp;quot;season_num_uk&amp;quot;, &amp;quot;series_name&amp;quot;}) do&lt;br /&gt;
		if (args[v]) then&lt;br /&gt;
			args[v] = args[v]:gsub(&amp;quot;\127[^\127]*UNIQ%-%-(%a+)%-%x+%-QINU[^\127]*\127&amp;quot;, &amp;quot;&amp;quot;)	-- Remove all strip-markers.&lt;br /&gt;
			args[v] = args[v]:gsub(&amp;quot;&amp;lt;/? *br */?&amp;gt;&amp;quot;, &amp;quot; &amp;quot;)					-- Replace &amp;lt;br /&amp;gt; (and variants) with space character.&lt;br /&gt;
			args[v] = args[v]:gsub(&amp;quot;%b&amp;lt;&amp;gt;[^&amp;lt;]+%b&amp;lt;&amp;gt;&amp;quot;, &amp;quot;&amp;quot;)					-- Remove html markup.&lt;br /&gt;
			args[v] = args[v]:gsub(&amp;quot;%b&amp;lt;&amp;gt;&amp;quot;, &amp;quot;&amp;quot;)							-- Remove self-closed html tags.&lt;br /&gt;
			if i ~= 4 then&lt;br /&gt;
				args[v] = args[v]:gsub(&amp;quot;%[%[[^|]+|([^%]]+)%]%]&amp;quot;, &amp;quot;%1&amp;quot;)	-- Remove wiki-link retain label.&lt;br /&gt;
			else&lt;br /&gt;
				args[v] = args[v]:gsub(&amp;quot;%[%[([^|]+)|.*%]%]&amp;quot;, &amp;quot;%1&amp;quot;)		-- Remove wiki-link retain article.&lt;br /&gt;
			end&lt;br /&gt;
			args[v] = args[v]:gsub(&amp;quot;%[%[([^%]]+)%]%]&amp;quot;, &amp;quot;%1&amp;quot;)			-- Remove wiki-link retain article.&lt;br /&gt;
			args[v] = args[v]:gsub(&amp;quot;%[%S+ +([^%]]-)%]&amp;quot;, &amp;quot;%1&amp;quot;)			-- Remove URLs retain label.&lt;br /&gt;
			args[v] = args[v]:gsub(&amp;quot;%[[^%]]-%]&amp;quot;, &amp;quot;&amp;quot;)					-- Remove all remaining URLs.&lt;br /&gt;
&lt;br /&gt;
			if (args[v] == &amp;quot;&amp;quot;) then										-- Check if the value is an empty string.&lt;br /&gt;
				args[v] = nil											-- The value is an empty string; Set it to nil.&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return args&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Public function - main process.&lt;br /&gt;
--- @param frame table The frame invoking the module.&lt;br /&gt;
--- @param args table The key-value parameters passed to the module.&lt;br /&gt;
function television._getShortDescription(frame, args)&lt;br /&gt;
	args = cleanValues(args)&lt;br /&gt;
	local tvSeriesName, tvSeriesNameDab = getTVSeriesName(args.series_name, args.not_dab)&lt;br /&gt;
    local seasonNumber, seasonTextStyle = getSeasonNumberAndTextStyle(args.season_num, args.season_num_uk)&lt;br /&gt;
	local seasonOrdinalNumber = getSeasonOrdinalNumber(seasonNumber)&lt;br /&gt;
	local episodeOrdinalNumbers = getEpisodeOrdinalNumbers(args.episode_num)&lt;br /&gt;
	local limitedSeries = isLimitedSeries(args.limited, tvSeriesNameDab)&lt;br /&gt;
	&lt;br /&gt;
	local descriptionType = getDescriptionType(&lt;br /&gt;
			tvSeriesName,&lt;br /&gt;
			seasonOrdinalNumber,&lt;br /&gt;
			episodeOrdinalNumbers,&lt;br /&gt;
			args.special,&lt;br /&gt;
			limitedSeries&lt;br /&gt;
	)&lt;br /&gt;
&lt;br /&gt;
	local shortDescription, trackingCat = getShortDescriptionByType(&lt;br /&gt;
			descriptionType,&lt;br /&gt;
			tvSeriesName,&lt;br /&gt;
			seasonOrdinalNumber,&lt;br /&gt;
            seasonTextStyle,&lt;br /&gt;
			episodeOrdinalNumbers,&lt;br /&gt;
			args.special,&lt;br /&gt;
			limitedSeries&lt;br /&gt;
	)&lt;br /&gt;
&lt;br /&gt;
	-- Check if the invoking page is from /testcases or /doc pages.&lt;br /&gt;
	if (args.test) then&lt;br /&gt;
		return shortDescription, trackingCat&lt;br /&gt;
	elseif (args.doc) then&lt;br /&gt;
		return shortDescription&lt;br /&gt;
	else&lt;br /&gt;
		local tableData = {shortDescription, &amp;quot;noreplace&amp;quot;}&lt;br /&gt;
		return frame:expandTemplate({title = &amp;quot;short description&amp;quot;, args = tableData}) .. trackingCat&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--- Public function which is used to create a television episode&amp;#039;s short description&lt;br /&gt;
--- from the data available in [Template:Infobox television episode].&lt;br /&gt;
--- A suitable description will be generated depending on the values of the various parameters.&lt;br /&gt;
--- See documentation for examples.&lt;br /&gt;
---&lt;br /&gt;
--- Parameters:&lt;br /&gt;
--- |episode_num=		— optional; The episode&amp;#039;s number.&lt;br /&gt;
--- |season_num=		— optional; The season&amp;#039;s number.&lt;br /&gt;
--- |season_num_uk=		— optional; The season&amp;#039;s number if using the British &amp;quot;series&amp;quot; term.&lt;br /&gt;
--- |series_name=		— optional; The TV series name.&lt;br /&gt;
--- |not_dab=			— optional; Set if the TV series name has parentheses as part of its name.&lt;br /&gt;
--- |special=			— optional; Setting to &amp;quot;yes&amp;quot; will set the description as a &amp;quot;special episode&amp;quot;.&lt;br /&gt;
---							Any other value will replace the word &amp;quot;special&amp;quot; with the one entered.&lt;br /&gt;
---							For example &amp;quot;special=recap&amp;quot; will create &amp;quot;recap episode&amp;quot;.&lt;br /&gt;
---	|limited=			— optional; Set if the series is a single season series, such as miniseries or limited series&lt;br /&gt;
---							and does not need a season number as part of the description.&lt;br /&gt;
--- @param frame table The frame invoking the module.&lt;br /&gt;
function television.getShortDescription(frame)&lt;br /&gt;
	local getArgs = require(&amp;quot;Module:Arguments&amp;quot;).getArgs&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	return television._getShortDescription(frame, args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Public function which is used for testing output only.&lt;br /&gt;
--- @param frame table The frame invoking the module.&lt;br /&gt;
function television.test(frame)&lt;br /&gt;
	local getArgs = require(&amp;quot;Module:Arguments&amp;quot;).getArgs&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
&lt;br /&gt;
	test = args.test&lt;br /&gt;
	local shortDescription, categories = television._getShortDescription(frame, args)&lt;br /&gt;
&lt;br /&gt;
	if (test == &amp;quot;cat&amp;quot;) then&lt;br /&gt;
		return categories&lt;br /&gt;
	else&lt;br /&gt;
		return shortDescription&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return television&lt;/div&gt;</summary>
		<author><name>Randombell</name></author>
	</entry>
</feed>