Content deleted Content added
tooltips |
for fun, show characters in tooltip of character count |
||
Line 36:
local Latn_pattern = table.concat {
'[',
'\n\32-\127',
'\194\160-\194\172',
'\195\128-\195\191',
'\196\128-\197\191',
'\198\128-\201\143',
'\225\184\128-\225\187\191',
'\226\177\160-\226\177\191',
'\234\156\160-\234\159\191',
'\234\172\176-\234\173\175',
'\239\172\128-\239\172\134',
'\239\188\129-\239\188\188',
'–',
'—',
'«', '»',
']',
};
Line 188:
local singles = script_data.singles
local ranges = script_data.ranges
local function clear (self)
end
end
local counts = {}
Line 195 ⟶ 201:
self[script_code] = (self[script_code] or 0) + (amount or 1)
end,
clear =
}
▲ for _, key in ipairs(m_table.keysToList(self, false)) do
})
▲ self[key] = nil
local codepoints_per_script = {}
setmetatable(codepoints_per_script, {
__index = {
add = function(self, script_code, codepoint)
self[script_code] = self[script_code] or { n = 0 }
if self[script_code].n <= 0x20
or codepoint <= 0x1F)) then
if self[script_code].n == 0x20 then
local period = ('.'):byte()
for _ = 1, 3 do
self[script_code].n = self[script_code].n + 1
self[script_code][self[script_code].n] = period
end
else
if script_code == "Zinh" then -- probably combining character
self[script_code].n = self[script_code].n + 1
self[script_code][self[script_code].n] = 0x25CC
end
self[script_code].n = self[script_code].n + 1
self[script_code][self[script_code].n] = codepoint
end
end
end,
clear = clear,
}
})
Line 217 ⟶ 246:
if singles[codepoint] then
counts:increment(singles[codepoint])
codepoints_per_script:add(singles[codepoint], codepoint)
codepoint = codepoint + 1
else
Line 223 ⟶ 253:
local count = 0
while codepoint <= range[2] and codepoint <= block[2] do
▲ codepoint = codepoint + 1
count = count + 1
codepoints_per_script:add(range[3], codepoint)
codepoint = codepoint + 1
end
counts:increment(range[3], count)
Line 254 ⟶ 285:
fun.map(
function (count, script)
return ('<abbr title="%s">%s</abbr> (<span title="%s">%d</span>)
:format(
script_data.aliases[script], script,
and mw.text.nowiki(mw.ustring.char(
unpack(codepoints_per_script[script])))
or "",
count)
end,
Line 267 ⟶ 301:
", "))
end
-- mw.logObject(codepoints_per_script, block[3])
counts:clear()
codepoints_per_script:clear()
end
output:insert "|}"
|