Zum Inhalt springen

Modul:Navbox: Unterschied zwischen den Versionen

669 Bytes hinzugefügt ,  vor 7 Jahren
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)
Zeile 57: Zeile 57:
end
end


local function addNewline(s)
local function processItem(item, nowrapitems)
if s:match('^[*:;#]') or s:match('^{|') then
if item:sub(1, 2) == '{|' then
return '\n' .. s ..'\n'
-- Applying nowrap to lines in a table does not make sense.
else
-- Add newlines to compensate for trim of x in |parm=x in a template.
return s
return '\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' .. item ..'\n'
end
end
return item
end
end


Zeile 139: Zeile 154:
:css('font-size', '114%')
:css('font-size', '114%')
:css('margin', '0 4em')
:css('margin', '0 4em')
:wikitext(addNewline(args.title))
:wikitext(processItem(args.title))
end
end


Zeile 164: Zeile 179:
:attr('colspan', getAboveBelowColspan())
:attr('colspan', getAboveBelowColspan())
:tag('div')
:tag('div')
:wikitext(addNewline(args.above))
:wikitext(processItem(args.above, args.nowrapitems))
end
end


Zeile 178: Zeile 193:
:attr('colspan', getAboveBelowColspan())
:attr('colspan', getAboveBelowColspan())
:tag('div')
:tag('div')
:wikitext(addNewline(args.below))
:wikitext(processItem(args.below, args.nowrapitems))
end
end


Zeile 197: Zeile 212:
:attr('rowspan', 2 * #listnums - 1)
:attr('rowspan', 2 * #listnums - 1)
:tag('div')
:tag('div')
:wikitext(addNewline(args.imageleft))
:wikitext(processItem(args.imageleft))
end
end


Zeile 257: Zeile 272:
:tag('div')
:tag('div')
:css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
:css('padding', (index == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
:wikitext(addNewline(listText))
:wikitext(processItem(listText, args.nowrapitems))


if index == 1 and args.image then
if index == 1 and args.image then
Zeile 269: Zeile 284:
:attr('rowspan', 2 * #listnums - 1)
:attr('rowspan', 2 * #listnums - 1)
:tag('div')
:tag('div')
:wikitext(addNewline(args.image))
:wikitext(processItem(args.image))
end
end
end
end
Zeile 325: Zeile 340:
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end
if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end


for i, cat in ipairs(getTrackingCategories()) do
for _, cat in ipairs(getTrackingCategories()) do
builder:wikitext('[[Category:' .. cat .. ']]')
builder:wikitext('[[Category:' .. cat .. ']]')
end
end
Zeile 371: Zeile 386:
args = navboxArgs
args = navboxArgs


for k, v in pairs(args) do
for k, _ in pairs(args) do
local listnum = ('' .. k):match('^list(%d+)$')
if type(k) == 'string' then
if listnum then table.insert(listnums, tonumber(listnum)) end
local listnum = k:match('^list(%d+)$')
if listnum then table.insert(listnums, tonumber(listnum)) end
end
end
end
table.sort(listnums)
table.sort(listnums)
Anonymer Benutzer