Module:Color

可在Module:Color/doc创建此模块的帮助文档

local p = {}

function p.color(color, text, background)
    local s = "<span class=\"effect-%s\" style=\"color: %s; white-space:nowrap; font-weight:bold;"
    
    if color == "green" then s = string.format(s, "green", "#008000")
    elseif color == "red" then s = string.format(s, "red", "#ff0000")
    elseif color == "yellow" then s = string.format(s, "yellow", "#ffbd00")
    elseif color == "blue" then s = string.format(s, "blue", "#0000ff")
    elseif color == "cyan" then s = string.format(s, "cyan", "#23ceff")
    elseif color == "grey" then s = string.format(s, "grey", "#b0b0b0")
    elseif color == "lilac" then s = string.format(s, "lilac", "#c3b091")
    elseif color == "orange" then s = string.format(s, "orange", "#ffa500")
    elseif color == "white" then s = string.format(s, "white", "#ffffff")
    else s = string.format(s, "black", "#000000") end
    
    if background then
        s = s .. " background: #E9E9E9; padding: 1px 3px; border-radius: 2px;"
    end
    
    s = s .. "\">"
    return s .. text .. "</span>"
end

return p