Module:Color
From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search
| This module is rated as ready for general use. It is considered stable and may be used wherever appropriate. Improvements should be developed and tested in a sandbox before changing the live module. |
local p = {}
function p.normalize(frame)
local color = frame.args[1] or ""
color = mw.text.trim(color)
if color:match("^#%x%x%x$") or
color:match("^#%x%x%x%x$") or
color:match("^#%x%x%x%x%x%x$") or
color:match("^#%x%x%x%x%x%x%x%x$") then
return color
end
if color:match("^%x%x%x$") or
color:match("^%x%x%x%x$") or
color:match("^%x%x%x%x%x%x$") or
color:match("^%x%x%x%x%x%x%x%x$") then
return "#" .. color
end
return color
end
return p