48,406
edits
(Created page with "local subexport = {} local m_str_utils = require("Module:string utilities") local cp = m_str_utils.codepoint local floor = math.floor local insert = table.insert local min = math.min local sort = table.sort local split = m_str_utils.split -- Copied from Module:Unicode data. local function binaryRangeSearch(codepoint, ranges) local low, mid, high low, high = 1, ranges.length or require "Module:table".length(ranges) while low <= high do mid = floor((low + high)...") |
No edit summary |
||
| Line 1: | Line 1: | ||
local subexport = {} | local subexport = {} | ||
local | local require_when_needed = require("Module:require when needed") | ||
local cp = | local cp = require_when_needed("Module:string utilities", "codepoint") | ||
local floor = math.floor | local floor = math.floor | ||
local get_plaintext = require_when_needed("Module:utilities", "get_plaintext") | |||
local get_script = require_when_needed("Module:scripts", "getByCode") | |||
local insert = table.insert | local insert = table.insert | ||
local ipairs = ipairs | |||
local min = math.min | local min = math.min | ||
local pairs = pairs | |||
local setmetatable = setmetatable | |||
local sort = table.sort | local sort = table.sort | ||
local split = | local split = require_when_needed("Module:string utilities", "split") | ||
local table_len = require_when_needed("Module:table", "length") | |||
local type = type | |||
-- Copied from [[Module:Unicode data]]. | -- Copied from [[Module:Unicode data]]. | ||
local function binaryRangeSearch(codepoint, ranges) | local function binaryRangeSearch(codepoint, ranges) | ||
local low, mid, high | local low, mid, high | ||
low, high = 1, ranges.length or | low, high = 1, ranges.length or table_len(ranges) | ||
while low <= high do | while low <= high do | ||
mid = floor((low + high) / 2) | mid = floor((low + high) / 2) | ||
| Line 176: | Line 183: | ||
local scripts = setmetatable({}, scripts_mt) | local scripts = setmetatable({}, scripts_mt) | ||
text = | text = get_plaintext(text) | ||
local combined_scripts = { | local combined_scripts = { | ||
| Line 215: | Line 222: | ||
bestScript = bestScript or "None" | bestScript = bestScript or "None" | ||
return | return get_script(bestScript) | ||
end | end | ||
return subexport | return subexport | ||