local p = {}
p.ca = function(f)
local args = f:getParent().args
local linkTarget = args[1]
local linkText = args[2] or args[1]
local outputMode = args[3] or "text"
local tagsSplit = args[4] or args[1]
if args[1] == nil then return '' end
local output = p.main(linkTarget, linkText, outputMode, tagsSplit)
return output
end
p.cci = function(f)
local args = f:getParent().args
local linkTarget = args[1]
local linkText = args[2] or args[1]
local outputMode = "image"
local tagsSplit = args[3] or args[1]
if args[1] == nil then return '' end
local output = p.main(linkTarget, linkText, outputMode, tagsSplit)
return output
end
p.main = function(linkTarget, linkText, outputMode, tagsSplit)
local tags = {}
if string.find(tagsSplit, '&') ~= nil then
if string.find(tagsSplit, '%(') ~= nil then
local split = mw.text.split(tagsSplit,' %(')
if string.find(split[2],'&') then
--format: Tomomo (Casual & Sweet Eater)
local disambig = mw.text.split(string.gsub(split[2],'%)',''),' & ')
tags[1] = mw.text.trim(split[1] .. ' (' .. disambig[1] .. ')')
tags[2] = mw.text.trim(split[1] .. ' (' .. disambig[2] .. ')')
else
--format: Sora & Sham (Cuties)
tags[1] = string.gsub(tagsSplit, '[ &%(%)]', '_')
end
else
--format: Tomato & Mimyuu
tags = mw.text.split(tagsSplit,' & ')
end
else
tags[1] = string.gsub(tagsSplit, '[ %(%)]', '_')
end
local tagOutput = tags[1] .. '"'
if table.maxn(tags)>1 then
tagOutput = 'multiple" data-tt-tags=\'['
for i,v in ipairs(tags) do
tagOutput = tagOutput .. '"'..v..'"'
if i < table.maxn(tags) then
tagOutput = tagOutput .. ', '
end
end
tagOutput = tagOutput .. "]'"
end
local output
if outputMode == "image" then
output = '<span class="character-icon" data-card2="'.. linkTarget ..'" style="white-space:pre;"><span title="'.. linkTarget ..'"><span class="ajaxttlink -'..tagOutput
output = output ..'>[[File:'.. linkTarget ..'.png|alt=|'.. linkText ..'|link='.. linkTarget ..']]</span></span></span>'
else
output = '<span class="character-icon" data-card2="'.. linkTarget ..'" style="white-space:pre;">[['.. linkTarget ..'|<span class="ajaxttlink -'..tagOutput
output = output .. '>'..linkText..'</span>]]</span>'
end
return output
end
return p
Advertisement
Module:Ca
Advertisement