Module:Dièse couleur web

From CryptoWiki

Revision as of 05:56, 3 May 2021 by wiki_crypto>Od1n (support de la notation hexadécimale RGBA (pour ajouter un niveau de transparence) ; CSS Color Module Level 4)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Dièse couleur web/doc

local p = {}

function p.couleur(value)
    if value:sub(1, 1) == '#' then
        return '#' .. value:sub(2)
    elseif (#value == 6 or #value == 3 or #value == 8 or #value == 4) and value:match('^%x+$') then
        return '#' .. value
    else
        return value
    end
end

function p.main(frame)
    local value = mw.text.trim(frame.args[1])
    return p.couleur(value)
end

return p