local p = {}
local getArgs = require('Module:Arguments').getArgs
local function createTableBody(startHex, endHex)
local body = mw.html.create("tbody")
--header
local labelRow = tbody:tag("tr")
labelRow:tag("th")--empty corner cell
for colIndex=0, 15 do
labelRow:tag("th")
:cssText("width:20pt")
:wikitext(string.format("%X", colIndex))
end
--fill cells
local startInt = tonumber(startHex:sub(1, -2), 16)
local endInt = tonumber(endHex:sub(1, -2), 16)
for rowIndex=startInt, endInt do
local row = tbody:tag("tr")
local rowHex = string.format("%X", rowIndex)
row:tag("th"):wikitext('U+'.. rowHex .. 'x')
for colIndex=0, 15 do
row:tag("td"):wikitext('&#x'.. rowHex .. string.format("%X", colIndex) .. ';')
end
end
return tostring(tab)
end
function p.main(frameArg)
frame = frameArg
local args = getArgs(frame)
local body = ""
if args['block-range-start'] and args['block-range-end'] then
body = createTableBody(args['block-range-start'],
args['block-range-end'])
end
local tableHTML = mw.html.create("table")
:addClass("unicode-block")
:wikitext(body)
return tostring(tableHTML)
end
return p