Anonymous user
Module:Color contrast: Difference between revisions
better error checking
(typos) |
(better error checking) |
||
Line 153:
local style = (args[1] or ''):lower()
local bg, fg = (args[2] or 'white'), (args[3] or 'black')
local lum_bg, lum_fg = 1, 0
local slist = mw.text.split(style or '', ';')
Line 161 ⟶ 162:
v = v or ''
if (k:match('^[%s]*(background)[%s]*$') or k:match('^[%s]*(background-color)[%s]*$')) then
if( lum ~= '' ) then bg, lum_bg = v, lum end
elseif (k:match('^[%s]*(color)[%s]*$')) then
if( lum ~= '' ) then bg, lum_fg = v, lum end
end
end
if lum_bg > lum_fg then
else
return (lum_fg + 0.05)/(lum_bg + 0.05)
end
end
|