Module:Ep/sandbox

local p = {} -- function to retrieve and format the episode name function p.ep(frame) local reference = false -- convert the input into the standardized epCode local epMatcher = require('Module:Ep/Matcher') local epCode = epMatcher.matchCode(frame, reference) -- get the title and pagename for that epCode local epInfo = require('Module:Ep/Info') local epName = epInfo.title(epCode) local pageName = epInfo.pagename(epCode) -- if there is no epCode code, then just return the episode name without any further formatting if not isnotempty(epCode) then return epName end -- (epCode) local small = mw.html.create('small') small :wikitext("(" .. epCode .. ")")   -- formatting with the various parameters of     local text = frame.args["text"] or nil local nolink = frame.args["nolink"] or nil local bold = frame.args["bold"] or nil local plain = frame.args["plain"] or nil local hide = frame.args["hide"] or nil -- error message if code doesn't exist if epCode == '0x00' or not isnotempty(epName) then return " Undefined Episode " end local epValue if pageName ~= epName then epValue = pageName .. '|' .. epName elseif isnotempty(pageName) then epValue = pageName else epValue = '' end if isnotempty(text) and not isnotempty(nolink) then epValue = pageName .. "|" .. text elseif isnotempty(text) and isnotempty(nolink) then epValue = text end

if isnotempty(nolink) and not isnotempty(text) then epValue = epValue else epValue = "" .. epValue .. "" end if isnotempty(bold) then epValue = "'''" .. epValue .. "'''" end if not isnotempty(plain) then epValue = "\"" .. epValue .. "\"" end local fullEpValue = epValue .. " " .. tostring(small) if isnotempty(hide) then return epValue else return fullEpValue end end -- function to determine that a variable has a value function isnotempty(s) return s ~= nil and s~= '' end return p