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 epInput = frame.args["ep"] local epMatcher = require('Module:Ep/Matcher') local epCode = epMatcher.matchCode(epInput, 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 after = frame.args["after"] or nil local bold = frame.args["bold"] or nil local plain = frame.args["plain"] or nil local hide = frame.args["hide"] or nil if epCode == '0x00' or not isnotempty(epName) then local pageName = 'Unknown episode' local epName = pageName end if pageName ~= epName then local epValue = pageName .. '|' .. epName elseif isnotempty(pageName) then local epValue = pageName else epValue = '' end

if isnotempty(nolink) then epValue = epValue else epValue = "" .. epValue .. "" end if isnotempty(after) then epValue = epValue .. after 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