2023年政策修订增补工作正在进行中,欢迎参与!
Module:Gochicolor
跳转到导航
跳转到搜索
local hex_table = mw.loadData("Module:Gochicolor/Dataset")
local p = {}
local function find_hex(chara, colortype)
local hex
hex = hex_table[chara] and hex_table[chara][colortype]
if hex then
return hex
else
hex = hex_table["default"]["base"]
return hex
end
end
function p.code(frame)
local chara = frame.args[1]
local colortype = frame.args[2]
local hex_code = find_hex(chara, colortype)
return mw.text.nowiki(hex_code)
end
function p.block(frame)
local chara = frame.args[1]
local hex_text = frame.args[2]
local hex_block = find_hex(chara, "base")
local chara_link = find_hex(chara, "link")
local block = '<span style="width:0.8em; height:0.8em; background-color:' .. hex_block .. ';display:inline-block;"></span>'
local text = block .. ' [[:' .. chara_link .. '|' .. chara .. ']]'
if hex_text then
if hex_text == "color" then
hex_text = find_hex(chara, "dark")
end
text = block .. ' [[:' .. chara_link .. '|<span style="color:' .. hex_text .. '">' .. chara .. '</span>]]'
end
return text
end
return p