Module:Color contrast: Difference between revisions

better error checking
No edit summary
(better error checking)
Line 152:
function p._styleratio(args)
local style = (args[1] or ''):lower()
local bg, fg = (args[2] or 'white'), (args[3] or 'black')
local lum_bg, lum_fg = 1, 0
 
if args[2] then
local lum = color2lum(args[2])
if lum ~= '' then bg, lum_bg = args[2], lum end
end
if args[3] then
local lum = color2lum(args[3])
if lum ~= '' then fg, lum_fg = args[3], lum end
end
 
local slist = mw.text.split(style or '', ';')
Anonymous user