A documentação para este módulo pode ser criada em Módulo:Appearances/doc
local A = { }
local HF = require("Módulo:HF")
local parent = nil
local build = function(arg, arg2, category)
local built = ""
local link = ""
local text = ""
if not HF.isempty(arg) then
link = arg
if not HF.isempty(arg2) then
text = arg2
else
link = string.match(arg, "([^%[%|%]]+)")
text = string.match(arg, "%|([^%]%|]+)")
end
if string.find(link, "w:c:") == nil and string.find(link, "Glossário:") == nil and string.find(link, "#") == nil then
if not HF.isempty(link) and not HF.isempty(text) then
built = string.format("[[%s|%s]][[Categoria:%s%s]]", link, text, link, category)
elseif not HF.isempty(link) and HF.isempty(text) then
built = string.format("[[%s]][[Categoria:%s%s]]", link, link, category)
else
built = arg
end
else
built = arg
end
end
return built
end
local suffixTag = function(text)
local tag = mw.html.create( 'span' )
:css( 'color', 'darkgreen' )
:css( 'font-weight', 'bold' )
:css( 'font-style', 'italic' )
:css( 'font-size', 'smaller' )
:wikitext('('..text..')')
:done()
return tostring(tag)
end
function A.appearances(frame)
parent = frame:getParent()
local arg = parent.args[1]
local arg2 = parent.args[2]
local arg3 = parent.args[3]
local category = '/Aparições'
local output = ''
if HF.isempty(arg3) then
output = build(arg, arg2, category)
else
output = build(arg, arg2, category) .. ' ' .. suffixTag(arg3)
end
return output
end
function A.apn(frame)
parent = frame:getParent()
local arg = parent.args[1]
local arg2 = nil
local category = '/Aparições'
local output = ''
output = build(arg, arg2, category)
return output
end
function A.mentions(frame)
parent = frame:getParent()
local arg = parent.args[1]
local arg2 = parent.args[2]
local arg3 = parent.args[3]
local category = '/Menções'
local output = ''
if HF.isempty(arg3) then
output = string.format('%s %s', build(arg, arg2, category), suffixTag('mencionado(a)'))
else
output = string.format('%s %s', build(arg, arg2, category), suffixTag(arg3))
end
return output
end
function A.minor(frame)
parent = frame:getParent()
local arg = parent.args[1]
local arg2 = parent.args[2]
local arg3 = parent.args[3]
local category = '/Aparições_Menores'
local output = ''
if HF.isempty(arg3) then
output = build(arg, arg2, category)
else
output = string.format('%s %s', build(arg, arg2, category), suffixTag(arg3))
end
return output
end
function A.invocations(frame)
parent = frame:getParent()
local arg = parent.args[1]
local arg2 = parent.args[2]
local arg3 = parent.args[3]
local category = '/Invocações'
local output = ''
if HF.isempty(arg3) then
output = string.format('%s %s', build(arg, arg2, category), suffixTag('invocado(a)'))
else
output = string.format('%s %s', build(arg, arg2, category), suffixTag(arg3))
end
return output
end
return A