Module:BSicon catalogue
Jump to navigation
Jump to search
Lua
CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules
For using BSicon catalogue, please refer to the documentation at Template:BSicon catalogue.
Code
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p._main(args)
local presets = {
['1'] = '', -- was BSa1
['1c'] = '%1,u%1,f%1,g%1,%1 maroon,%1 red,%1 orange,%1 saffron,%1 yellow,%1 golden,%1 olive,%1 lime,%1 green,%1 jade,%1 teal,%1 cyan,%1 deepsky,%1 azure,%1 sky,%1 cerulean,%1 blue,%1 denim,%1 lavender,%1 purple,%1 violet,%1 fuchsia,%1 ruby,%1 pink,%1 carrot,%1 ochre,%1 brown,%1 steel,%1 grey,%1 black', -- new
['2'] = ',ex', -- was BSa
['2p'] = '%1%2,%1ex%2', -- was BSa
['2c'] = '%1,ex%1,u%1,uex%1,f%1,fex%1,g%1,gex%1,%1 maroon,ex%1 maroon,%1 red,ex%1 red,%1 orange,ex%1 orange,%1 saffron,ex%1 saffron,%1 yellow,ex%1 yellow,%1 golden,ex%1 golden,%1 olive,ex%1 olive,%1 lime,ex%1 lime,%1 green,ex%1 green,%1 jade,ex%1 jade,%1 teal,ex%1 teal,%1 cyan,ex%1 cyan,%1 deepsky,ex%1 deepsky,%1 azure,ex%1 azure,%1 sky,ex%1 sky,%1 cerulean,ex%1 cerulean,%1 blue,ex%1 blue,%1 denim,ex%1 denim,%1 lavender,ex%1 lavender,%1 purple,ex%1 purple,%1 violet,ex%1 violet,%1 fuchsia,ex%1 fuchsia,%1 ruby,ex%1 ruby,%1 pink,ex%1 pink,%1 carrot,ex%1 carrot,%1 ochre,ex%1 ochre,%1 brown,ex%1 brown,%1 steel,ex%1 steel,%1 grey,ex%1 grey,%1 black,ex%1 black', -- new
['2i'] = '%1…%2!%1INT%2,ex%1INT%2,%1ACC%2,ex%1ACC%2,%1ACCx%2,ex%1ACCx%2,%1HSTACC%2,ex%1HSTACC%2,%1HSTACCx%2,ex%1HSTACCx%2,%1INTACC%2,ex%1INTACC%2', -- was BSaIA
['3'] = ',e,x,ex', -- was BSa6x
['3p'] = '%1%2,%1e%2,%1x%2,%1ex%2', -- was BSa6x
['4'] = ',ex,u,uex', -- was BSa4
['4e'] = ',e,ex,u,ue,uex', -- was BSa4e
['4x'] = ',x,ex,u,ux,uex', -- was BSa4x
['4m'] = ',ex,m,exm,um,uexm,u,uex', -- new
['4v'] = 'v-,v-ex,vex-,exv-,uv-,uv-ex,uvex-,uexv-', -- was BSa4x2
['4vp'] = '%1v%2-%3,%1v%2-ex%3,%1vex%2-%3,ex%1v%2-%3,u%1v%2-%3,u%1v%2-ex%3,u%1vex%2-%3,uex%1v%2-%3', -- new
['4mv'] = 'v-,v-ex,vex-,exv-,mv-,mv-ex,mvex-,exmv-,umv-,umv-ex,umvex-,uexmv-,uv-,uv-ex,uvex-,uexv-', -- new
['4mvp'] = '%1v%2-%3,%1v%2-ex%3,%1vex%2-%3,ex%1v%2-%3,m%1v%2-%3,m%1v%2-ex%3,m%1vex%2-%3,exm%1v%2-%3,um%1v%2-%3,um%1v%2-ex%3,um%1vex%2-%3,uexm%1v%2-%3,u%1v%2-%3,u%1v%2-ex%3,u%1vex%2-%3,uex%1v%2-%3', -- new
['5'] = ',ex,t,ext,u,uex,ut,uext', -- was BSa5
['5m'] = ',ex,t,ext,m,exm,mt,exmt,um,uexm,umt,uexmt,u,uex,ut,uext', -- new
['5v'] = 'v-,v-ex,vex-,exv-,tv-,tv-ex,tvex-,extv-,uv-,uv-ex,uvex-,uexv-,utv-,utv-ex,utvex-,uextv-', -- was BSa5x2
['5mv'] = 'v-,v-ex,vex-,exv-,tv-,tv-ex,tvex-,extv-,mv-,mv-ex,mvex-,exmv-,mtv-,mtv-ex,mtvex-,exmtv-,umv-,umv-ex,umvex-,uexmv-,umtv-,umtv-ex,umtvex-,uexmtv-,uv-,uv-ex,uvex-,uexv-,utv-,utv-ex,utvex-,uextv-', -- new
['6'] = ',e,x,ex,u,ue,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] = '%1%2%3%4!' .. -- first of each quadruple in 6xm4
'%1m%2%3%4,%1xm%2%3%4,%1m%2%3x%4,ex%1m%2%3%4,u%1m%2%3%4,u%1xm%2%3%4,u%1m%2%3x%4,uex%1m%2%3%4',
['6xm1b'] = '%1%2%3%4!' .. -- second of each quadruple in 6xm4
'%1%2%3m%4,%1%2%3xm%4,%1x%2%3m%4,ex%1%2%3m%4,u%1%2%3m%4,u%1%2%3xm%4,u%1x%2%3m%4,uex%1%2%3m%4',
['6xm1c'] = '%1%2%3%4!' .. -- third
'%1%4%3m%2,%1%4%3xm%2,%1x%4%3m%2,ex%1%4%3m%2,u%1%4%3m%2,u%1%4%3xm%2,u%1x%4%3m%2,uex%1%4%3m%2',
['6xm1d'] = '%1%2%3%4!' .. -- fourth
'%1m%4%3%2,%1xm%4%3%2,%1m%4%3x%2,ex%1m%4%3%2,u%1m%4%3%2,u%1xm%4%3%2,u%1m%4%3x%2,uex%1m%4%3%2',
['6xm1r'] = '%1%2%3%4!' .. -- 6xm2 with specific eight columns omitted
'%1m%2%3%4,%1m%2%3x%4,%1x%2%3m%4,ex%1m%2%3%4,u%1m%2%3%4,u%1m%2%3x%4,u%1x%2%3m%4,uex%1m%2%3%4',
['6xm2'] = '%1%2%3%4!' .. -- first two of each quadruple in 6xm4
'%1m%2%3%4,%1%2%3m%4,%1xm%2%3%4,%1%2%3xm%4,' ..
'%1m%2%3x%4,%1x%2%3m%4,ex%1m%2%3%4,ex%1%2%3m%4,' ..
'u%1m%2%3%4,u%1%2%3m%4,u%1xm%2%3%4,u%1%2%3xm%4,' ..
'u%1m%2%3x%4,u%1x%2%3m%4,uex%1m%2%3%4,uex%1%2%3m%4',
['6xm2f'] = '%1%2%3%4!' .. -- last two of each quadruple in 6xm4
'%1%4%3m%2,%1m%4%3%2,%1%4%3xm%2,%1xm%4%3%2,' ..
'%1x%4%3m%2,%1m%4%3x%2,ex%1%4%3m%2,ex%1m%4%3%2,' ..
'u%1%4%3m%2,u%1m%4%3%2,u%1%4%3xm%2,u%1xm%4%3%2,' ..
'u%1x%4%3m%2,u%1m%4%3x%2,uex%1%4%3m%2,uex%1m%4%3%2',
['6xm4'] = '%1%2%3%4!' .. -- one quadruple per line, comma separated
'%1m%2%3%4,%1%2%3m%4,%1%4%3m%2,%1m%4%3%2,' ..
'%1xm%2%3%4,%1%2%3xm%4,%1%4%3xm%2,%1xm%4%3%2,' ..
'%1m%2%3x%4,%1x%2%3m%4,%1x%4%3m%2,%1m%4%3x%2,' ..
'ex%1m%2%3%4,ex%1%2%3m%4,ex%1%4%3m%2,ex%1m%4%3%2,' ..
'u%1m%2%3%4,u%1%2%3m%4,u%1%4%3m%2,u%1m%4%3%2,' ..
'u%1xm%2%3%4,u%1%2%3xm%4,u%1%4%3xm%2,u%1xm%4%3%2,' ..
'u%1m%2%3x%4,u%1x%2%3m%4,u%1x%4%3m%2,u%1m%4%3x%2,' ..
'uex%1m%2%3%4,uex%1%2%3m%4,uex%1%4%3m%2,uex%1m%4%3%2',
['6xm2sf'] = '%1%2%3%4!' .. -- as 6xm2, but mix set f instead of set u
'mf%1m%2%3%4,mf%1%2%3m%4,mf%1xm%2%3%4,mf%1%2%3xm%4,' ..
'mf%1m%2%3x%4,mf%1x%2%3m%4,exmf%1m%2%3%4,exmf%1%2%3m%4,' ..
'f%1m%2%3%4,f%1%2%3m%4,f%1xm%2%3%4,f%1%2%3xm%4,' ..
'f%1m%2%3x%4,f%1x%2%3m%4,fex%1m%2%3%4,fex%1%2%3m%4',
['6xm2sfu'] = '%1%2%3%4!' .. -- as 6xm2, mix sets f and u (experimental)
'uf%1m%2%3%4,uf%1%2%3m%4,uf%1xm%2%3%4,uf%1%2%3xm%4,' ..
'uf%1m%2%3x%4,uf%1x%2%3m%4,uexf%1m%2%3%4,uexf%1%2%3m%4,' ..
'fu%1m%2%3%4,fu%1%2%3m%4,fu%1xm%2%3%4,fu%1%2%3xm%4,' ..
'fu%1m%2%3x%4,fu%1x%2%3m%4,fexu%1m%2%3%4,fexu%1%2%3m%4',
['6xm_2'] = (('%1%2%3%4%5!' .. -- first two of each quadruple in 6xm_4
' %1%2 m%3%4 %5, %1%2 %3%4 m%5, %1%2 m%3%4x%5, %1%2 %3%4xm%5,' ..
' %1%2 m%5%4x%3, %1%2 %5%4xm%3, ex%1%2 m%3%4 %5, ex%1%2 %3%4 m%5,' ..
' u%1%2 m%3%4 %5, u%1%2 %3%4 m%5, u%1%2 m%3%4x%5, u%1%2 %3%4xm%5,' ..
' u%1%2 m%5%4x%3, u%1%2 %5%4xm%3,uex%1%2 m%3%4 %5, uex%1%2 %3%4 m%5'
):gsub(" ","")),
['6xm_4'] = (('%1%2%3%4%5!' .. -- one quadruple per line
' %1%2 m%3%4 %5, %1%2 %3%4 m%5, %1%2 %5%4 m%3, %1%2 m%5%4 %3,' ..
' %1%2 m%3%4x%5, %1%2 %3%4xm%5, %1%2x%5%4 m%3, %1%2xm%5%4 %3,' ..
' %1%2 m%5%4x%3, %1%2 %5%4xm%3, %1%2x%3%4 m%5, %1%2xm%3%4 %5,' ..
' ex%1%2 m%3%4 %5, ex%1%2 %3%4 m%5, ex%1%2 %5%4 m%3, ex%1%2 m%5%4 %3,' ..
' u%1%2 m%3%4 %5, u%1%2 %3%4 m%5, u%1%2 %5%4 m%3, u%1%2 m%5%4 %3,' ..
' u%1%2 m%3%4x%5, u%1%2 %3%4xm%5, u%1%2x%5%4 m%3, u%1%2xm%5%4 %3,' ..
' u%1%2 m%5%4x%3, u%1%2 %5%4xm%3, u%1%2x%3%4 m%5, u%1%2xm%3%4 %5,' ..
'uex%1%2 m%3%4 %5, uex%1%2 %3%4 m%5, uex%1%2 %5%4 m%3, uex%1%2 m%5%4 %3'
):gsub(" ","")),
['7'] = ',e,x,ex,t,et,xt,ext,h,eh,xh,exh,u,ue,ux,uex,ut,uet,uxt,uext,uh,ueh,uxh,uexh', -- was BSa7
['7x'] = '%1%2%3%4,%1%2x%3%4,%1x%2%3%4,%1%3x%2%4,ex%1%2%3%4,t%1%2%3%4,t%1%2x%3%4,t%1x%2%3%4,t%1%3x%2%4,ext%1%2%3%4,h%1%2%3%4,h%1%2x%3%4,h%1x%2%3%4,h%1%3x%2%4,exh%1%2%3%4,u%1%2%3%4,u%1%2x%3%4,u%1x%2%3%4,u%1%3x%2%4,uex%1%2%3%4,ut%1%2%3%4,ut%1%2x%3%4,ut%1x%2%3%4,ut%1%3x%2%4,uext%1%2%3%4,uh%1%2%3%4,uh%1%2x%3%4,uh%1x%2%3%4,uh%1%3x%2%4,uexh%1%2%3%4', -- was BSa7x
['7x1'] = '%1%2%3,%1%2x%3,%1x%2%3,ex%1%2%3,t%1%2%3,t%1%2x%3,t%1x%2%3,ext%1%2%3,h%1%2%3,h%1%2x%3,h%1x%2%3,exh%1%2%3,u%1%2%3,u%1%2x%3,u%1x%2%3,uex%1%2%3,ut%1%2%3,ut%1%2x%3,ut%1x%2%3,uext%1%2%3,uh%1%2%3,uh%1%2x%3,uh%1x%2%3,uexh%1%2%3', -- was BSa7x
['7x2'] = '%1%2%3%4,%1%2x%3%4,%1%3x%2%4,ex%1%2%3%4,t%1%2%3%4,t%1%2x%3%4,t%1%3x%2%4,ext%1%2%3%4,h%1%2%3%4,h%1%2x%3%4,h%1%3x%2%4,exh%1%2%3%4,u%1%2%3%4,u%1%2x%3%4,u%1%3x%2%4,uex%1%2%3%4,ut%1%2%3%4,ut%1%2x%3%4,ut%1%3x%2%4,uext%1%2%3%4,uh%1%2%3%4,uh%1%2x%3%4,uh%1%3x%2%4,uexh%1%2%3%4', -- was BSa7x
['7c'] = ',e,x,ex,t,et,xt,ext,h,eh,xh,exh', -- for BSicon/Catalogue/railway/other colors
['7x1c'] = '%1%2%3,%1%2x%3,%1x%2%3,ex%1%2%3,t%1%2%3,t%1%2x%3,t%1x%2%3,ext%1%2%3,h%1%2%3,h%1%2x%3,h%1x%2%3,exh%1%2%3', -- for BSicon/Catalogue/railway/other colors
['7x2c'] = '%1%2%3%4,%1%2x%3%4,%1%3x%2%4,ex%1%2%3%4,t%1%2%3%4,t%1%2x%3%4,t%1%3x%2%4,ext%1%2%3%4,h%1%2%3%4,h%1%2x%3%4,h%1%3x%2%4,exh%1%2%3%4', -- for BSicon/Catalogue/railway/other colors
['7pc'] = '%1%2,%1e%2,%1x%2,%1ex%2,%1t%2,%1et%2,%1xt%2,%1ext%2,%1h%2,%1eh%2,%1xh%2,%1exh%2', -- for BSicon/Catalogue/railway/other colors
['7x1pc'] = '%1%2%3%4,%1%2%3x%4,%1%2x%3%4,%1ex%2%3%4,%1t%2%3%4,%1t%2%3x%4,%1t%2x%3%4,%1ext%2%3%4,%1h%2%3%4,%1h%2%3x%4,%1h%2x%3%4,%1exh%2%3%4', -- for BSicon/Catalogue/railway/other colors
['7x2pc'] = '%1%2%3%4%5,%1%2%3x%4%5,%1%2%4x%3%5,%1ex%2%3%4%5,%1t%2%3%4%5,%1t%2%3x%4%5,%1t%2%4x%3%5,%1ext%2%3%4%5,%1h%2%3%4%5,%1h%2%3x%4%5,%1h%2%4x%3%5,%1exh%2%3%4%5', -- for BSicon/Catalogue/railway/other colors
['8'] = ',ex,t,ext,h,exh,u,uex,ut,uext,uh,uexh', -- was BSa8
['8c'] = ',ex,t,ext,h,exh', -- for BSicon/Catalogue/railway/other colors
['8pc'] = '%1%2,%1ex%2,%1t%2,%1ext%2,%1h%2,%1exh%2', -- for BSicon/Catalogue/railway/other colors
['8m'] = ',ex,t,ext,h,exh,m,exm,mt,exmt,mh,exmh,um,uexm,umt,uexmt,umh,uexmh,u,uex,ut,uext,uh,uexh', -- new
['8v'] = 'v-,v-ex,vex-,exv-,tv-,tv-ex,tvex-,extv-,hv-,hv-ex,hvex-,exhv-,uv-,uv-ex,uvex-,uexv-,utv-,utv-ex,utvex-,uextv-,uhv-,uhv-ex,uhvex-,uexhv-', -- new
['9'] = ',e,x,ex,t,et,xt,ext,u,ue,ux,uex,ut,uet,uxt,uext', -- was BSaV
['9m'] = ',e,x,ex,m,em,xm,exm,mt,emt,xmt,exmt,umt,uemt,uxmt,uexmt,um,uem,uxm,uexm,u,ue,ux,uex', -- new
['9mo'] = '!m,em,xm,exm,mt,emt,xmt,exmt,umt,uemt,uxmt,uexmt,um,uem,uxm,uexm', -- new, 9m 'mixed only'
['9x'] = '%1%2%3%4,%1%2x%3%4,%1x%2%3%4,%1%3x%2%4,ex%1%2%3%4,t%1%2%3%4,t%1%2x%3%4,t%1x%2%3%4,t%1%3x%2%4,ext%1%2%3%4,u%1%2%3%4,u%1%2x%3%4,u%1x%2%3%4,u%1%3x%2%4,uex%1%2%3%4,ut%1%2%3%4,ut%1%2x%3%4,ut%1x%2%3%4,ut%1%3x%2%4,uext%1%2%3%4', -- new
['9x1'] = '%1%2%3,%1%2x%3,%1x%2%3,ex%1%2%3,t%1%2%3,t%1%2x%3,t%1x%2%3,ext%1%2%3,u%1%2%3,u%1%2x%3,u%1x%2%3,uex%1%2%3,ut%1%2%3,ut%1%2x%3,ut%1x%2%3,uext%1%2%3', -- new
['9x2'] = '%1%2%3%4,%1%2x%3%4,%1%3x%2%4,ex%1%2%3%4,t%1%2%3%4,t%1%2x%3%4,t%1%3x%2%4,ext%1%2%3%4,u%1%2%3%4,u%1%2x%3%4,u%1%3x%2%4,uex%1%2%3%4,ut%1%2%3%4,ut%1%2x%3%4,ut%1%3x%2%4,uext%1%2%3%4', -- new
['9c'] = ',e,x,ex,t,et,xt,ext', -- for BSicon/Catalogue/railway/other colors
['9pc'] = '%1%2,%1e%2,%1x%2,%1ex%2,%1t%2,%1et%2,%1xt%2,%1ext%2', -- for BSicon/Catalogue/railway/other colors
['10'] = 't,ext,h,exh,ht,exht,ut,uext,uh,uexh,uht,uexht', -- new
['11'] = 't,et,xt,ext,h,eh,xh,exh,ht,eht,xht,exht,ut,uet,uxt,uext,uh,ueh,uxh,uexh,uht,ueht,uxht,uexht', -- new
['12'] = 'C,exC,D,exD,uC,uexC,uD,uexD', -- new
['13'] = 'C,eC,xC,exC,D,eD,xD,exD,uC,ueC,uxC,uexC,uD,ueD,uxD,uexD', -- new
['14'] = ',ex,t,ext,h,exh,C,exC,D,exD,u,uex,ut,uext,uh,uexh,uC,uexC,uD,uexD', -- new
['51'] = '%1…%2!%1RD1%2,%1RP1%2,%1RP2%2,%1RP4%2,%1vRP2%2,%1RA%2,%1RM%2,%1RB%2,%1RR%2,%1RG%2,%1RY%2,%1RE%2', -- new
['51f'] = '%1…%2!%1RA%2,%1RM%2,%1RB%2,%1RR%2,%1RG%2,%1RY%2,%1RE%2', -- was BSaR
['51g'] = '%1…%2!%1RD1%2,%1RP1%2,%1RP2%2,%1RP4%2,%1vRP2%2', -- was RPa
['51k'] = '%1…%2!%1SKRZ-GD%2,%1SKRZ-G1%2,%1SKRZ-G2%2,%1SKRZ-G4%2,%1SKRZ-A%2,%1SKRZ-M%2,%1SKRZ-B%2,%1SKRZ-R%2,%1SKRZ-G%2,%1SKRZ-Y%2,%1SKRZ-E%2', -- new
['51kf'] = '%1…%2!%1SKRZ-A%2,%1SKRZ-M%2,%1SKRZ-B%2,%1SKRZ-R%2,%1SKRZ-G%2,%1SKRZ-Y%2,%1SKRZ-E%2', -- was RPaS
['51kg'] = '%1…%2!%1SKRZ-GD%2,%1SKRZ-G1%2,%1SKRZ-G2%2,%1SKRZ-G4%2', -- was RPaN
}
presets['6xm'] = presets['6xm2']
local match = mw.ustring.match
local ret = { '{|' }
ret.insert = table.insert
local i = 1
while args[i] do
local id_format = args['format'..(i>1 and i or '')]
id_format = id_format or args['prefixes'..(i>1 and i or '')]
local preset = ((not id_format) and (args['preset'..(i>1 and i or '')] or '4'))
id_format = presets[preset] or id_format or ',ex,u,uex'
if not (i>1) then
ret:insert('class="wikitable BSicon-catalogue ')
if not args.header then
if match(id_format, '%%[2-9]') or match(id_format, '%%1[^,]+') or match(id_format, '-') then
ret:insert('vertical-headers ')
end
end
ret:insert(preset and 'BSc-p-'..preset..' ' or '')
ret:insert(args.class and args.class..' ' or '')
ret:insert('"\n')
end
for _, row in ipairs(p.tablechunk(args, id_format, i)) do
ret:insert(row)
end
i = i + 1
end
ret:insert('|}')
return table.concat(ret)
end
function p.tablechunk(args, id_format, chunk)
-- Define often-used functions
local gsub = mw.ustring.gsub
local format = string.format
local match = mw.ustring.match
local trim = mw.text.trim
local split = mw.text.split
local insert = table.insert
local header, header1, parallel, row, rows
local multi = match(gsub(args[chunk], '~~[^\n]*', ''), '\\')
if not args[chunk] then -- for those who don't escape equals signs
return error('<code>1=</code> missing')
end
local id1_format
if match(id_format, '!') then
id1_format = gsub(id_format, '^(.*)![^!]*$', '%1')
id_format = gsub(id_format, '^.*!([^!]*)$', '%1')
end
if not match(id_format, '%%') then -- to check if conversion is needed
if match(id_format, '-') then
id_format = gsub(','..id_format, ',([^,]*)-([^,]*)', ',%1%%1-%2%%2')
if id1_format then
id1_format = gsub(id1_format, '^([^,]*)-([^,]*)$', '%1%%1-%2%%2') or id1_format
end
else
id_format = gsub(','..id_format, ',([^,]*)', ',%1%%1')
if id1_format then
id1_format = gsub(id1_format, '^([^,]*)$', '%1%%1') or id1_format
end
end
id_format = gsub(id_format, '^,', '')
end
local function icon_format(var)
var = split(trim(var), ':')
local str = gsub(','..id_format, ',([^,]*)', ('\n|[[File:BSicon %1.svg|x20px|border| ]]'))
for i = 1, 9 do
if var[i] then
str = gsub(str, '%%'..i, var[i])
end
end
str = gsub(str, '%%[1-9]', '') -- remove remaining markers
return str
end
local t = split(mw.text.trim(args[chunk]), '\n') -- columns based on first row
local row_format
id1_format = id1_format or gsub(id_format, '^([^,]*).*$', '%1')
if match(id_format, '%%[2-9]') then
id1_format = gsub(id1_format, '%%([1-9])', '<span class="BSc-%1">%%%1</span>')
else
id1_format = gsub(id1_format, '%%1', '<span class="BSc-c">%%1</span>')
end
local id1_match = '^([^:]*):?([^:]*):?([^:]*):?([^:]*):?([^:]*):?([^:]*):?([^:]*):?([^:]*):?([^:]*)$'
if not multi then
row_format = function(var)
insert(rows, '\n|-\n| ' .. gsub(var, id1_match, id1_format))
insert(rows, (icon_format(var)))
end
else
row_format = function(var)
insert(rows, '\n|-')
var = split(var, '\\')
if #var > multi then multi = #var end
for i, v in ipairs(var) do
if match(v, '%*') then
if i%2 == 0 then
insert(rows, '\n|class="BSc-t BSc-e" colspan="'.. (#split(id_format, ',') + 1) ..'"|' .. gsub(v, '%*(.*)$', '%1'))
else
insert(rows, '\n|class="BSc-t" colspan="'.. (#split(id_format, ',') + 1) ..'"|' .. gsub(v, '%*(.*)$', '%1'))
end
else
if i%2 == 0 then
insert(rows, '\n|class="BSc-n BSc-e"|' .. gsub(v, id1_match, id1_format))
insert(rows, (gsub((icon_format(v)), '\n|', '\n|class="BSc-e"|')))
else
insert(rows, '\n|class="BSc-n"|' .. gsub(v, id1_match, id1_format))
insert(rows, (icon_format(v)))
end
end
end
end
local n, tmp, tmp2 = 1
while not tmp do
if not match(t[n], '^!') then
tmp2 = split(t[n], '~~')
if tmp2[2] or (tmp2[1] ~= '') then
tmp = #split(tmp2[1], '\\')
end
end
n = n + 1
end
multi = tmp
end
if args['header'..(chunk>1 and chunk or '')] then
header = args['header'..(chunk>1 and chunk or '')]
else
if tonumber(args.width) then args.width = args.width.."px" end
header = mw.clone(id_format)
if match(id_format, '%%[2-9]') or match(id_format, '%%1[^,]+') then
header1 = gsub(gsub(id1_format, '%%', ''), '<(/?)span', '<%1var')
if match(id_format, '%%[2-9]') then
header = gsub(header, '%%([1-9])', '<var class="BSc-%1">%1</var>')
else
header = gsub(header, '%%1', '<var class="BSc-c">1</var>')
end
local tmp = '\n!<div>' .. gsub(header, ',', '</div>\n!<div>') .. '</div>\n!'
header = '!' .. (args.width and 'style="width:' .. args.width .. '" class="BSc-h"|' or 'class="BSc-h"|') .. header1 .. (multi and tmp .. mw.ustring.rep((args.width and 'style="width:' .. args.width .. '" class="BSc-h"|' or 'class="BSc-h"|') .. header1 .. tmp, (multi - 1)) or tmp)
else
header = gsub(header, '%%1', '')
header = (multi and header .. mw.ustring.rep((args.width and ',style="width:' .. args.width .. '" class="BSc-h"| ,' or ',class="BSc-h"| ,') .. header, (multi - 1)) or header)
header = '!' .. (args.width and 'style="width:' .. args.width .. '" class="BSc-h"| \n!' or 'class="BSc-h"| \n!') .. gsub(header, ',', '\n!') .. '\n!'
end
end
if args.note then header = header .. args.note end
rows = {'|-\n', header}
local colspan
for i, v in ipairs(t) do
if match(v, '^!') then
colspan = colspan or (#split(id_format, ',') + 1) * (multi or 1) + 1
insert(rows, (gsub(gsub(v, '^!=', '!\n='), '^!', '\n|-\n!colspan="'.. colspan ..'"|')))
else
v = split(v, '~~')
if v[2] or (v[1] ~= '') then
row_format(v[1])
insert(rows, '\n| ' .. (v[2] or '') .. (v[3] and ' <span class="BSc-s">' .. v[3] .. '</span>' or ''))
if v[4] then insert(rows, ' – ' .. (v[4] or '') .. (v[5] and ' <span class="BSc-s">' .. v[5] .. '</span>' or '')) end
end
end
end
insert(rows, '\n|-\n')
insert(rows, header)
insert(rows, '\n')
return rows
end
function p.main(frame)
local args = getArgs(frame, {parentFirst = true})
return p._main(args)
end
return p