Module:C

local C = { }

local HF = require("Module:HF") local parent = nil local noLink = true

function C.build(arg, arg2, noLink, swapIssue) local built = "" if not HF.isempty(arg) then link = arg if not HF.isempty(arg2) then text = arg2 end

title = string.match(arg, "(.+) Vol ") if HF.isempty(title) then title = string.match(arg, "(.+) #") if HF.isempty(title) then title = "Title Failed" end end volume = string.match(arg, "Vol ([^%s]+)") if HF.isempty(volume) then volume = "1" end if not HF.isempty(swapIssue) then issue = swapIssue end if HF.isempty(issue) then issue = string.match(arg, " #(.+)$") end if HF.isempty(issue) then issue = string.match(arg, "Vol [^%s]+ (.+)$") end if HF.isempty(issue) then issue = "Issue Failed" end if volume == "1" then poundTitle = ("" .. title .. " #" .. issue ) else poundTitle = ("" .. title .. " Vol " .. volume .. " #" .. issue ) end linkTitle = title .. " Vol " .. volume .. " " .. issue if string.find(title, "—") == nil and string.find(title, "%[") == nil and string.find(string.lower(title), "cnst") == nil then local noText = HF.isempty(text) if noLink and noText then built = linkTitle elseif noLink then built = text elseif not noLink and noText then built = "" .. poundTitle .. "" else built = "" .. text .."" end else built = arg end end if string.find(built, " Failed") ~= nil then built = arg end return built

end

function C.reference(frame) local output = "" local first = "" local second = "" parent = frame:getParent local arg = parent.args[1] local arg2 = parent.args[2] if HF.isempty(arg) then first = "Reference Needed" else first = C.build(arg, "", false, "") end if not HF.isempty(arg2) and (string.len(arg2) < 4) then second = "-" .. C.build(arg, arg2, false, arg2) elseif not HF.isempty(arg2) then second = arg2 end if string.match(first, "%[") == nil then output = HF.Link(first) .. second else output = first .. second end

return output end

function C.referenceName(frame) local output = "" local name = "" parent = frame:getParent local arg = parent.args[1] local arg2 = parent.args[2] if HF.isempty(arg) then name = "Reference Needed" else name = C.build(arg, arg2, true, "") name = string.gsub(name, ":", "") end if not HF.isempty(arg2) and (string.len(arg2) < 4) then name = name .. "-" .. arg2 end

output = name return output end

function C.comic(frame) parent = frame:getParent local arg = parent.args[1] local arg2 = parent.args[2] local output = "" output = C.build(arg, arg2, false, "") return output end

function C.comicNL(frame) parent = frame:getParent local arg = parent.args[1] local arg2 = parent.args[2] local output = "" output = C.build(arg, arg2, true, "") return output end

return C