Difference between revisions of "Module:Dièse couleur web"

From CryptoWiki

wiki_crypto>Od1n
(support de la notation hexadécimale RGBA (pour ajouter un niveau de transparence) ; CSS Color Module Level 4)
 
m (1 revision imported)
 

Latest revision as of 08:31, 2 January 2022

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