Module:SeasonVariables

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 07:16, 19 July 2023 by Vish (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:SeasonVariables/doc

local p = {}

function p.main(frame)
    local input = frame.args[1]
    local abbreviations = {
        PB = "Phantom Blood",
        BT = "Battle Tendency",
        SC = "Stardust Crusaders",
        DU = "Diamond is Unbreakable",
        GW = "Golden Wind",
        SO = "Stone Ocean",
        SBR = "Steel Ball Run",
        JJL = "JoJolion",
        TJL = "The JOJOLands"
    }
    local abbreviation, episode_number, title
    for abbr, full_name in pairs(abbreviations) do
        episode_number, title = string.match(input, "(%w+) Episode (%d+): (.+)")
        if episode_number and not string.find(input, "%(") then
            return "''[[JoJo's Bizarre Adventure: The Animation]]'' Episode " .. episode_number .. ": " .. title
        elseif string.find(input, abbr) then
            return "''[[" .. full_name .. "]]'' " .. string.sub(input, string.len(abbr) + 2)
        end
    end
    return input
end

return p