Module:Navbox/sandbox: Difference between revisions

Content deleted Content added
can use |orphan=yes to disable Category:Navbox orphans and to fix odd/even markers in a child navbox
implement nowrapitems=yes to apply nowrap to lines in a list item per Template talk:Navbox#Merging nowrap navbox using idea from recently deleted Module:Navbox with nowrap lists
Line 57:
end
 
local function addNewlineprocessItem(sitem, nowrapitems)
if sitem:matchsub('^[*:;#]'1, 2) or== s:match('^{|') then
-- Applying nowrap to lines in a table does not make sense.
return '\n' .. s ..'\n'
-- Add newlines to compensate for trim of x in |parm=x in a template.
else
return s'\n' .. item ..'\n'
end
if nowrapitems == 'yes' then
local lines = {}
for line in (item .. '\n'):gmatch('([^\n]*)\n') do
local prefix, content = line:match('^([*:;#]+)%s*(.*)')
if prefix and not content:match('^<span class="nowrap">') then
line = prefix .. '<span class="nowrap">' .. content .. '</span>'
end
table.insert(lines, line)
end
item = table.concat(lines, '\n')
end
if item:match('^[*:;#]') then
return '\n' .. sitem ..'\n'
end
return item
end
 
Line 139 ⟶ 154:
:css('font-size', '114%')
:css('margin', '0 4em')
:wikitext(addNewlineprocessItem(args.title))
end
 
Line 164 ⟶ 179:
:attr('colspan', getAboveBelowColspan())
:tag('div')
:wikitext(addNewlineprocessItem(args.above, args.nowrapitems))
end
 
Line 178 ⟶ 193:
:attr('colspan', getAboveBelowColspan())
:tag('div')
:wikitext(addNewlineprocessItem(args.below, args.nowrapitems))
end
 
Line 197 ⟶ 212:
:attr('rowspan', 2 * #listnums - 1)
:tag('div')
:wikitext(addNewlineprocessItem(args.imageleft))
end
 
Line 257 ⟶ 272:
:tag('div')
:css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
:wikitext(addNewlineprocessItem(listText, args.nowrapitems))
 
if index == 1 and args.image then
Line 269 ⟶ 284:
:attr('rowspan', 2 * #listnums - 1)
:tag('div')
:wikitext(addNewlineprocessItem(args.image))
end
end
Line 372 ⟶ 387:
 
for k, v in pairs(args) do
local listnum = tostring('' .. k):match('^list(%d+)$')
if listnum then table.insert(listnums, tonumber(listnum)) end
end