Content deleted Content added
m gah |
add chars_in_scripts_in_block function |
||
Line 78:
end)),
", ")
local function get_chars_in_scripts(iterator, state, value)
local script_to_char_set = {}▼
for codepoint in iterator, state, value do
script_to_char_set[script] = script_to_char_set[script] or {}▼
end
return script_to_char_set
end
local function print_char_set_map(script_to_char_set, format, separator)
format = format or "%s: %s"
separator = separator or "\n"
function (_, codepoint)
return mw.ustring.char(codepoint)
end,▼
end,
m_table.sortedPairs(script_to_char_set)),
separator)
end
Line 88 ⟶ 116:
return expand_range(char1, char2)
end)
▲ local script_to_char_set = {}
for char in expanded_pattern:gmatch "[%z\1-\127\194-\244][\128-\191]*" do▼
▲ local script = Unicode_data.lookup_script(get_codepoint(char))
▲ script_to_char_set[script] = script_to_char_set[script] or {}
▲ script_to_char_set[script][char] = true
▲ end
--[[
mw.log(
print_char_set_map(
▲ table.concat(
get_chars_in_scripts(
▲ fun.mapIter(
▲ function (char_set, script)
▲ local char_list = m_table.keysToList(char_set)
▲ return ("%s: %s"):format(script, table.concat(char_list))
▲ end,
▲ m_table.sortedPairs(script_to_char_set)),
--]]
Line 112 ⟶ 128:
:gsub('^%s*', ''), -- Remove initial '\n ' to avoid creating unwanted pre element.
show_scripts(mw.ustring.gcodepoint(expanded_pattern)))
end
local function get_block_info_from_arg(args, arg)
local block_name = args[1]
return block_info
end
local function get_boolean_from_arg(args, arg)
end
function p.scripts_in_block(frame)
local
local show_block_name = get_boolean_from_arg(frame.args, 2)
▲ or error("Parameter 1 is required")
local script_list = show_scripts(fun.range(block_info[1], block_info[2]))
▲ local low, high = Unicode_data.get_block_range(block_name)
if
return ("%s: %s"):format(block_info[3], script_list)
▲ errorf("No block '%s' could be found", block_name)
else
return script_list
end
end
▲ local show_block_name = frame.args[2] and require "Module:Yesno" (frame.args[2])
function p.chars_in_scripts_in_block(frame)
local block_info = get_block_info_from_arg(frame.args, 1)
local show_block_name = get_boolean_from_arg(frame.args, 2)
local script_char_set_map = print_char_set_map(
get_chars_in_scripts(fun.range(block_info[1], block_info[2])))
if show_block_name then
return ("%s: %s"):format(
else
return script_char_set_map
end
end
|