Module:Navbox/sandbox: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
tweak nowrapping code
Jackmcbarn (talk | contribs)
Line 23:
return s
end
end
 
local function nowrapList(list)
local listLines = {}
for line in (list .. '\n'):gmatch('([^\n]*)\n') do
table.insert(listLines, (line:gsub('^([*:;]+[ \t]*)(.-)$', function(lineStart, lineContent)
if lineContent:match('^<span class="nowrap">') then
-- avoid the nowrap getting applied twice
return lineStart .. lineContent
else
return lineStart .. '<span class="nowrap">' .. lineContent .. '</span>'
end
end)))
end
return table.concat(listLines, '\n')
end
 
Line 347 ⟶ 332:
args = navboxArgs
 
local nowraplist = args.nowraplists and require('Module:Nowrap list')._main
for k, v in pairs(args) do
local listnum = string.match(k, '^list(%d+)$')
if listnum then table.insert(listnums, tonumber(listnum)) end
-- preprocess lists in listX, above, and below if nowraplists has been set
if args.nowraplistsnowraplist and (listnum or string.match(k, '^above') or string.match(k, '^below')) then
args[k] = nowrapListnowraplist(v)
end
end