Module:Sandbox/Erutuon: Difference between revisions

Content deleted Content added
allow inputting of pagename; error catching
create "scripts in blocks" table
Line 10:
end
end
 
local output_mt = {}
function output_mt:insert(str)
self.n = self.n + 1
self[self.n] = str
end
 
-- also in [[Module:Unicode data/documentation functions]]
function output_mt:insert_format(...)
self:insert(string.format(...))
end
 
output_mt.join = table.concat
 
output_mt.__index = output_mt
 
local function Output()
return setmetatable({ n = 0 }, output_mt)
end
 
 
local Latn_pattern = table.concat {
Line 153 ⟶ 173:
return script_list
end
end
 
function p.scripts_in_blocks(frame)
local output = Output()
local start = frame.args[1] and tonumber(frame.args[1], 16) or 0
local ending = frame.args[2] and tonumber(frame.args[2], 16) or 0x4000
output:insert [[
{| class="wikitable"
|+ Scripts in each Unicode block
! block !! codepoints !! scripts
]]
 
for _, block in pairs(mw.loadData "Module:Unicode data/blocks") do
if block[1] > ending then break end
if block[1] >= start then
output:insert_format([[
|-
| %s
| U+%04X–U+%04X
| %s
]], block[3], block[1], block[2], show_scripts(fun.range(block[1], block[2])))
end
end
output:insert "|}"
return output:join()
end