Module:Sncolor
跳到导航
跳到搜索
local p = {}
local baseColors = {
["高热"] = "color:#DB6B57",
["低温"] = "color:#6B7DD3",
["动能"] = "color:#E9EFEF; text-shadow:-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000",
["电击"] = "color:#E4E14F",
["特异"] = "color:#AF68DE",
["1"] = "color:#7A7A7A",
["2"] = "color:#65B14F",
["3"] = "color:#3662F1",
["4"] = "color:#C069D6",
["5"] = "color:#E99B36",
}
function p.color(frame)
local args = frame:getParent().args
local key = args[1] or ""
local text = args[2] or key
local style = baseColors[key]
-- 模糊匹配
if not style then
for k, v in pairs(baseColors) do
if mw.ustring.find(key, k) then
style = v
break
end
end
end
style = style or "color:inherit"
return string.format('<span style="%s">%s</span>', style, text)
end
return p