Jump to content

Module:Infobox rune and Module:Infobox rune/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
nix class
 
use require('strict') instead of require('Module:No globals')
 
Line 7: Line 7:


local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs

local function buildunicode(s)
local v = mw.text.split(s or '', '[^0-9A-F]')
local count = 0

for k = #v, 1, -1 do
if v[k] and v[k]:match('^[0-9A-F][0-9A-F][0-9A-F][0-9A-F]$') then
v[k] = '&#x' .. v[k] .. '; ' .. '<div style="display:block;font-size: 30%">U+' .. v[k] .. '</div>'
count = count + 1
else
table.remove(v, k)
end
end
if count > 1 then
local res = mw.html.create()
local row = res:tag('table')
:css('width', '100%')
:attr('role', 'presentation')
:tag('tr')
for k = 1,#v do
row:tag('td')
:css('width', math.floor(100/count) .. '%')
:wikitext(v[k])
end
return tostring(res)
elseif count > 0 then
return tostring(v[1])
end
end


local function addCells(row, entries, subcols, fs)
local function addCells(row, entries, subcols, fs)
Line 130: Line 99:
end
end
if pre == 'unicode hex' then
if pre == 'unicode hex' then
v = '&#x' .. v .. '; ' .. '<div style="font-size: 30%">U+' .. v .. '</div>'
v = buildunicode(v)
end
end
if num and num ~= '' then
if num and num ~= '' then
Line 295: Line 264:
:attr('scope', 'row')
:attr('scope', 'row')
:css('vertical-align', 'middle')
:css('vertical-align', 'middle')
:wikitext('Position in rune-row')
:css('line-height', '1.3em')
:wikitext('Position in<br>rune-row')
addCells(row, entries['position'], subcols, nil)
addCells(row, entries['position'], subcols, nil)
end
end