Module:Infobox television season name/sandbox2: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 57:
--- @param title string The article's title.
--- @return string | nil
local function getSeasonNumberNewgetSeasonNumber(title)
return match(title , "%d+", 1, -1, false, "")
end
Line 132:
name, _ = mw.ustring.gsub(name, "series %d*$", "")
name, _ = mw.ustring.gsub(name, "specials", "")
name, _ = mw.ustring.gsub(name, "story arc %d*$", "")
name = string.match(name, "^%s*(.-)%s*$") -- Trim spaces.
return name
Line 196 ⟶ 197:
local function getArticleTitleAndPipedLink(title, seasonNumberDiff)
local seasonType = getSeasonType(title)
local seasonNumber = getSeasonNumberNewgetSeasonNumber(title)
if tonumber(seasonNumber) == nil then
return "", nil
Line 311 ⟶ 312:
end
 
--- Returns an {{Italic title}} instance if title qualifies or a blank string.
--TODO: doc
 
--- @param frame table
--- @return string
function p.getItalicTitle(frame)
local getArgs = require("Module:Arguments").getArgs
local args = getArgs(frame)
-- If italic_title is set then "no" is the only valid value.
-- Don't set an italic title.
if args.italic_title then
return ""
Line 323 ⟶ 329:
title = getShowName(getTitleWithoutDisambiguation(title))
 
-- If the infobox is used on List of articles don't set an italic title.
-- TODO: this can be fixed in the future but current usages use a manual display title.
if string.find(title, "List of") then
return ""
end
 
italicTitle =return frame:expandTemplate{title = "Italic title", args = {string = title}}
return italicTitle
end
 
--- Returns the text used for the |above= field of the infobox.
--TODO: doc
---
--- @param frame table
--- @return string
function p.getAboveTitle(frame)
local getArgs = require("Module:Arguments").getArgs
Line 340 ⟶ 350:
end
 
--- Returns the relevant text used for the sub-header|subheader= field of the infobox.
---
--- The text is returned in the format of "Season #" or "Series #",
Line 363 ⟶ 373:
local title = getTitle(frame)
local titleWithoutDisambiguation = getTitleWithoutDisambiguation(title)
seasonNumber = getSeasonNumberNewgetSeasonNumber(titleWithoutDisambiguation)
seasonType = getSeasonType(titleWithoutDisambiguation)
-- For pages like "Doctor Who specials (2008–2010)".
if seasonType == "specials" then
returnlocal disambiguation = getDisambiguation(title) or "" .. " " .. seasonType
return disambiguation .. " " .. seasonType
end
seasonType = seasonType:sub(1, 1):upper() .. seasonType:sub(2)
Line 404 ⟶ 415:
local title = getTitle(frame)
local showName = getShowName(getTitleWithoutDisambiguation(title))
mw.log(title)
mw.log(showName)
if showName then
local disambiguation = getDisambiguation(title)
if disambiguation then
mw.log(showName)
disambiguation = " (" .. disambiguation .. ")"
end