Content deleted Content added
No edit summary |
No edit summary Tag: Reverted |
||
Line 37:
local function getCurrentSeasonNumberFromDisambiguation(disambiguation)
return match(disambiguation , "%d+", 1, -1, false, "")
end▼
--- Returns the disambiguation from the title.
--- @param title string The article's title.▼
--- @return string | nil▼
local function getDisambiguation(title)▼
local disambiguation = match(title, "%s%((.-)%)", 1, -1, false, "")▼
end▼
return disambiguation
end▼
--- Returns the title without its disambiguation.▼
--- @param title string The article's title.
--- @return string | nil
local function getTitleWithoutDisambiguation(title)▼
if disambiguation ~= "" then
return string.gsub(title, "%(" .. disambiguation .. "%)", "")▼
end
return title
end
Line 45 ⟶ 67:
--- @return string
local function getSeasonType(title)
return seasonType
end
end
-- Since rare cases exist such as "Doctor Who (2008–2010 specials)" and "Ben 10: Omniverse (story arc 1)"
-- if the default season type "season" is used at this point, do an extra validation to make sure the dismabiguation isn't used for these titles.
local disambiguation = getDisambiguation(title)
if disambiguation then
for _, seasonType in pairs(seasonTypes) do
if string.find(disambiguation, seasonType) then
return seasonType
end
end
end
return "season"
end
Line 64 ⟶ 99:
local function getSeasonNumberNew(title)
return match(title , "%d+", 1, -1, false, "")
▲end
▲--- Returns the title without its disambiguation.
▲--- @param title string The article's title.
▲--- @return string | nil
▲local function getTitleWithoutDisambiguation(title)
▲ local disambiguation = match(title, "%s%((.-)%)", 1, -1, false, "")
▲ if disambiguation ~= "" then
▲ return string.gsub(title, "%(" .. disambiguation .. "%)", "")
▲ end
▲ return title
▲end
▲local function getDisambiguation(title)
▲ return match(title, "%s%((.-)%)", 1, -1, false, "")
end
Line 201 ⟶ 220:
local disambiguation = getDisambiguation(title)
-- Titles such as "Big Brother 2 (American season) and Teenage Mutant Ninja Turtles (1987 TV series) season 2".
if disambiguation
local titleWithoutDisambiguation = string.gsub(title, disambiguation, "_DAB_")
modifiedTitle = string.gsub(titleWithoutDisambiguation, "%d+", seasonNumber)
Line 213 ⟶ 233:
-- Invalid usages of TV series articles with the television season infobox.
elseif disambiguation and (string.find(disambiguation, "TV series") and not (string.find(disambiguation, ", season") or string.find(disambiguation, ", series"))) then
return "", nil
Line 299 ⟶ 319:
function p.getSeasonWord(frame)
local title = getTitle(frame)
▲ title = getTitleWithoutDisambiguation(title)
local seasonType = getSeasonType(title)
if seasonType == "specials" then
Line 330 ⟶ 349:
if not seasonNumber then
local title = getTitle(frame)
seasonNumber = getSeasonNumberNew(
seasonType = getSeasonType(title)
--TODO: need to check where this is used
if seasonType == "specials" then
return
end
seasonType = seasonType:sub(1, 1):upper() .. seasonType:sub(2)
|