Module:Navbox: Difference between revisions

Jump to navigation Jump to search
update from Module:Navbox/sandbox per Template talk:Navbox#Merging nowrap navbox to implement nowrapitems=yes to nowrap listN + above + below text
(update from Module:Navbox/sandbox per talk; this implements automatic striping that applies to a navbox and any subgroup (child) navboxes it contains)
(update from Module:Navbox/sandbox per Template talk:Navbox#Merging nowrap navbox to implement nowrapitems=yes to nowrap listN + above + below text)
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 325 ⟶ 340:
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
 
for i_, cat in ipairs(getTrackingCategories()) do
builder:wikitext('[[Category:' .. cat .. ']]')
end
Line 371 ⟶ 386:
args = navboxArgs
 
for k, v_ in pairs(args) do
if type(k) == 'string' then
local listnum = ('' .. k):match('^list(%d+)$')
if local listnum then= table.insertk:match(listnums, tonumber'^list(listnum%d+)$') end
if listnum then table.insert(listnums, tonumber(listnum)) end
end
end
table.sort(listnums)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu