Module:Infobox television episode
![]() | This Lua module is used on approximately 13,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
![]() | This module depends on the following other modules: |
Module:Infobox television episode is used to validate parameter values for Template:Infobox television episode and Template:Infobox television crossover episode.
Functions
above_title
{{#invoke:Infobox television episode|above_title}}
Returns the text used for the |above=
field of the infobox.
episode_list
{{#invoke:Infobox television episode|episode_list}}
Returns the text used for the |episode_list=
field of the infobox.
italic_title
{{#invoke:Infobox television episode|italic_title}}
Returns an {{Italic dab2}} instance if title qualifies. Also returns a maintenance category if conditions are met.
The article's title is italicized if the series name is included in the article's title disambiguation. No italicization happens if one of the following conditions is met:
|italic_title=no
is set.- The article's title does not use disambiguation.
- No
|series=
value is set. - The article's disambiguation is not equal or does not include the series name.
The page is added to a maintenance category if the title is italicized and there is already an {{Italic dab}}, {{Italic title}} or {{DISPLAYTITLE}} template.
Infobox parameters checked:
|series=
|italic_title=
validate_values
{{#invoke:Infobox television episode|validate_values}}
Returns the relevant maintenance categories based on the {{Infobox television episode}} values validated.
Infobox television crossover episode function
validate_values_crossover
{{#invoke:Infobox television episode|validate_values_crossover}}
Returns the relevant maintenance categories based on the {{Infobox television crossover episode}} values validated.
See also
Maintenance categories
The module places relevant pages in the following maintenance categories:
- Category:Pages using infobox television with flag icon (0)
- Category:Pages using infobox television episode with image-related values without an image (5)
- Category:Pages using infobox television episode with incorrectly formatted values (50)
- Category:Pages using infobox television episode with non-matching title (9)
- Category:Pages using infobox television episode with nonstandard dates (14)
- Category:Pages using infobox television episode with unlinked values (1,085)
- Category:Pages using infobox television episode with unnecessary list markup (3,601)
- Category:Pages using infobox television episode with unnecessary manual displaytitle (11)
- Category:Pages using infobox television episode with unnecessary title parameter (9)
--- @module
local p = {}
--- Returns a maintenance category if unwanted values are found in the text.
---
--- Infobox parameters checked:
--- - |episode=
--- - |season=
--- - |series_no=
--- - |episode_list=
---
--- The function currently checks if the following values are present:
--- - ]] - links.
--- - '' - italics or bold.
---
---@param args table
---@return string | nil
local function are_values_unlinked_and_unformatted(args)
for _, parameter in pairs({args.episode, args.season, args.series_no, args.episode_list}) do
for _, bad_value in pairs({"]]", "''"}) do
if string.find(parameter, bad_value, 1, true) then
return "[[Category:Pages using infobox television episode with incorrectly formatted values]]"
end
end
end
end
--- Returns a maintenance category if the values use additional overall numbering.
---
--- Infobox parameters checked:
--- - |episode=
--- - |season=
--- - |series_no=
---
--- The function currently checks if the following values are present:
--- - overall - unsupported series overall numbering.
---
---@param args table
---@return string | nil
local function are_values_using_overall(args)
for _, parameter in pairs({args.episode, args.season, args.series_no}) do
if string.find(parameter, "overall") then
return "[[Category:Pages using infobox television episode with incorrectly formatted values]]"
end
end
end
--- Returns a maintenance category if the values are unlinked and if additional characters are found in the text.
---
--- Infobox parameters checked:
--- - |series=
--- - |prev=
--- - |next=
---
--- The function currently checks if a value is unlinked or if there is any additional character
--- before or after the linked text.
---
---@param args table
---@return string | nil
local function are_values_single_links(args)
for _, v in pairs({args.series, args.prev, args.next}) do
-- Check whether the values are linked.
if string.find(v, "%[%[.*%]%]") then
return "[[Category:Pages using infobox television episode with unlinked values]]"
end
-- Check whether the values have anything before or after link brackets.
if string.gsub(v, "(%[%[.*%]%])", "") ~= "" then
return "[[Category:Pages using infobox television episode with incorrectly formatted values]]"
end
end
end
--- Returns a maintenance category if there is no image file while image auxiliary values are present.
---
--- Infobox parameters checked:
--- - |image=
--- - |image_size=
--- - |image_upright=
--- - |image_alt=
--- - |alt=
--- - |caption=
---
---@param args table
---@return string
local function are_image_auxiliary_values_used_for_no_image(args)
if not args.image then
return ""
end
if args.image_size or args.image_upright or args.image_alt or args.alt or args.caption then
return "[[Category:Pages using infobox television episode with image-related values without an image]]"
end
end
--- Returns a maintenance category if the infobox title is equal to the article title
---
--- Infobox parameters checked:
--- - |title=
---
--- The function currently checks if the infobox title is equal to the article title while ignoring styling such as:
--- - nowrap spans.
--- - line breaks.
--- - Leading and trailing apostrophe spaces.
---
--- |page_title_test= is used for testing only.
---
---@param frame table
---@param args table
---@return string
local function is_infobox_title_equal_to_article_title(frame, args)
local article_title = args.page_title_test
if not args.page_title_test then
article_title = mw.title.getCurrentTitle().text
end
local _
article_title, _ = string.gsub(article_title, "%s+%b()$", "")
local space_single = frame:expandTemplate{title = "Space+single"}
local single_space = frame:expandTemplate{title = "Single+space"}
-- Convert the page name to use the "Space+single" and "Single+space" templates if a leading or trailing apostrophe is used.
local page_name, _ = string.gsub(string.gsub(article_title, "^'", space_single), "'$", single_space)
-- Remove nowrap span.
if string.find(args.title, "nowrap") then
local infobox_title = frame:expandTemplate{title = "Strip tags", args = {args.title}}
if infobox_title == page_name then
return ""
end
end
-- Remove line breaks and additional spaces as a result.
local title, _ = string.gsub(args.title, "<br%s?/?>", "")
title, _ = string.gsub(title, " ", " ")
if title == page_name then
return "[[Category:Pages using infobox television episode with unnecessary title parameter]]"
end
-- Article and infobox titles do not match.
return "[[Category:Pages using infobox television episode with non-matching title]]"
end
--- Returns the relevant maintenance categories based on the infobox values checked.
--- @param frame table
--- @return string
function p.verify_values(frame)
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
local categories = ""
categories = categories .. is_infobox_title_equal_to_article_title(frame, args)
categories = categories .. are_image_auxiliary_values_used_for_no_image(args)
categories = categories .. are_values_single_links(args)
categories = categories .. are_values_using_overall(args)
categories = categories .. are_values_unlinked_and_unformatted(args)
return categories
end
return p