Module:Dièse couleur web

From CryptoWiki

Revision as of 08:31, 2 January 2022 by 5imp5on (talk | contribs) (1 revision imported)
(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