Module:Navbox/sandbox: Difference between revisions

Content deleted Content added
pull some of the longer content in - should be just ws adjustment
correct implementation for needsHorizontalLists
Line 281:
:wikitext(processItem(args[cfg.arg.image]))
end
end
 
-- uses this now to make the needHlistCategory correct
-- TODO use later for when we add list styles via navbox
local function has_list_class(htmlclass)
local class_args = { -- rough order of probability of use
cfg.arg.bodyclass, cfg.arg.listclass, cfg.arg.aboveclass,
cfg.arg.belowclass, cfg.arg.titleclass, cfg.arg.navboxclass,
cfg.arg.groupclass, cfg.arg.titlegroupclass, cfg.arg.imageclass
}
local patterns = {
'^' .. htmlclass .. '$',
'%s' .. htmlclass .. '$',
'^' .. htmlclass .. '%s',
'%s' .. htmlclass .. '%s'
}
for _, arg in ipairs(class_args) do
for _, pattern in ipairs(patterns) do
if mw.ustring.find(args[arg] or '', pattern) then
return true
end
end
end
return false
end
 
Line 287 ⟶ 312:
return false
end
return not has_list_class(cfg.pattern.hlist) and not has_list_class(cfg.pattern.plainlist)
-- TODO: This should be finding the relevant classes, *not* checking equality
-- to be improved when we go looking for hlist and plainlist
return not (cfg.list_classes[args[cfg.arg.listclass]] or cfg.list_classes[args[cfg.arg.bodyclass]])
end
 
Line 301 ⟶ 324:
end
end
return false
end
 
local function hasBorders()
for _, key in ipairs({cfg.arg.groupstyletitlestyle, cfg.arg.basestylegroupstyle,
cfg.arg.basestyle, cfg.arg.abovestyle, cfg.arg.belowstyle}) do
if tostring(args[key]):find('border', 1, true) then
return true
end
end
return false
end
 
local function isIllegible()
local styleratio = require('Module:Color contrast')._styleratio
 
for key, style in pairs(args) do
if tostring(key):match(cfg.pattern.style) then