Module:Userbox: Difference between revisions
Content added Content deleted
m (not needed) |
(import userbox from wikipedia and remove codes about constrat) |
||
Line 293: | Line 293: | ||
return tostring(root) -- talk page |
return tostring(root) -- talk page |
||
end |
end |
||
-- local legible = true |
|||
-- local contrast = require('Module:Color contrast')._ratio |
|||
local function has_text(wikitext) |
|||
local function get_alt(text) |
|||
return text:match("|alt=([^|]*)") or "" |
|||
end |
|||
wikitext = wikitext:gsub("]]", "|]]") |
|||
wikitext = wikitext:gsub("%[%[%s*[Mm][Ee][Dd][Ii][Aa]%s*:[^|]-(|.-)]]", get_alt) |
|||
wikitext = wikitext:gsub("%[%[%s*[Ii][Mm][Aa][Gg][Ee]%s*:[^|]-(|.-)]]", get_alt) |
|||
wikitext = wikitext:gsub("%[%[%s*[Ff][Ii][Ll][Ee]%s*:[^|]-(|.-)]]", get_alt) |
|||
return mw.text.trim(wikitext) ~= "" |
|||
end |
|||
--[[ |
|||
-- not needed |
|||
if contrast { data.infoColor, data.backgroundColor, error = 0 } < 4.5 then |
|||
legible = false |
|||
end |
|||
if data.showId and contrast { data.idColor, data.idBackgroundColor, error = 0 } < 4.5 then |
|||
if has_text(data.id or "") then |
|||
legible = false |
|||
end |
|||
end |
|||
if data.showId2 and contrast { data.id2Color, data.id2BackgroundColor, error = 0 } < 4.5 then |
|||
if has_text(data.id2 or "") then |
|||
legible = false |
|||
end |
|||
end |
|||
if not legible then |
|||
root:wikitext('[' .. '[Category:Potentially illegible userboxes]' .. ']') |
|||
end |
|||
]]-- |
|||
return tostring(root) |
return tostring(root) |