Module:Navbox/sandbox: Difference between revisions

Content deleted Content added
test fix for code re-entry
Sync live template
Line 5:
local p = {}
 
local navbar = require('Module:Navbar/sandbox')._navbar
local getArgs -- lazily initialized
 
Line 54:
local regex = orphanCat:gsub('([%[%]])', '%%%1')
return (wikitext:gsub(regex, ''):gsub(REGEX_MARKER, changer)) -- () omits gsub count
end
 
local function colorlinks(v, s)
if v and v ~= '' and s and s ~= '' then
if not mw.ustring.match(v, '<span style') then
v = mw.ustring.gsub(v, '%[%[([^%[%]|]*)%]%]',
'[[%1|<span style="' .. s .. '>%1</span>]]')
v = mw.ustring.gsub(v, '%[%[([^%[%]|]*)|([^%[%]|]*)%]%]',
'[[%1|<span style="' .. s .. '>%2</span>]]')
end
end
return v
end
 
local function extractstyle(v1, v2, v3)
local r = ''
local v = (v1 or '') .. ';' .. (v2 or '') .. ';' .. (v3 or '')
local slist = mw.text.split(mw.ustring.gsub(mw.ustring.gsub(v, '&#[Xx]23;', '#'), '&#35;', '#'), ';')
for k = 1,#slist do
local s = slist[k]
if s:match('^[%s]*background') or s:match('^[%s]*color') then
r = r .. s .. ';'
end
end
return r
end
 
Line 110 ⟶ 85:
args.name,
mini = 1,
fontstyle = (args.basestyle or '') .. ';' .. (args.titlestyle or '') .. ';background:none transparent;border:none;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none; padding:0;'
})
end
Line 157 ⟶ 132:
renderNavBar(titleCell)
 
if (args.stylelinks or '') == 'yes' then
args.title = colorlinks(args.title,
extractstyle(args.basestyle, args.titlestyle, ''))
end
titleCell
:tag('div')
Line 186 ⟶ 156:
if not args.above then return end
 
if (args.stylelinks or '') == 'yes' then
args.above = colorlinks(args.above,
extractstyle(args.basestyle, args.abovestyle, ''))
end
tbl:tag('tr')
:tag('td')
Line 207 ⟶ 172:
if not args.below then return end
 
if (args.stylelinks or '') == 'yes' then
args.below = colorlinks(args.below,
extractstyle(args.basestyle, args.belowstyle, ''))
end
tbl:tag('tr')
:tag('td')
Line 249 ⟶ 209:
groupCell
:attr('id', mw.uri.anchorEncode(args.group1))
end
if (args.stylelinks or '') == 'yes' then
args['group' .. listnum] = colorlinks(args['group' .. listnum],
extractstyle(args.basestyle, args.groupstyle, args['group' .. listnum .. 'style']))
end
 
Line 261 ⟶ 216:
:addClass(args.groupclass)
:cssText(args.basestyle)
:css('width', args.groupwidth or '1%') -- If groupwidth not specified, minimize width
 
groupCell
Line 431 ⟶ 386:
args = navboxArgs
listnums = {}
 
for k, _ in pairs(args) do
if type(k) == 'string' then
Line 486 ⟶ 442:
renderTrackingCategories(res)
end
 
return striped(tostring(res))
end