Module:Userbox: Difference between revisions

1,084 bytes removed ,  7 years ago
import userbox from wikipedia and remove codes about constrat
m (not needed)
(import userbox from wikipedia and remove codes about constrat)
Line 293:
return tostring(root) -- talk page
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)