Content deleted Content added
list words in names |
Hope you don't mind me editing your userspace, but Module:Table has been merged |
||
(7 intermediate revisions by one other user not shown) | |||
Line 1:
local p = {}
local function
local content = mw.title.new("MediaWiki:Gadget-charinsert-core.js"):getContent()▼
local charinsert = content:match("charinsert: (%b{})")▼
if not charinsert then return "Could not find charinsert" end▼
return '"' .. in_quotes:gsub('"', '\\"') .. '"'▼
end)▼
return mw.getCurrentFrame():extensionTag{▼
name = "syntaxhighlight",▼
content = charinsert,▼
args = {▼
lang = "lua",▼
}▼
}▼
end▼
local codepoint_set = {}
for
end▼
end▼
end
▲ local codepoint_list = require "Module:table".keysToList(codepoint_set)
function p.JSON_character_names(str)
local codepoint_list = get_all_codepoints(str)
local Unicode = require "Module:Unicode data"
local JSON = {}
local len = 0
for i, codepoint in ipairs(codepoint_list) do
end▼
local key_and_value = '"' .. codepoint .. '":"' .. Unicode.lookup_name(codepoint) .. '"'
if len + added_len > 79 then
key_and_value = '\n' .. key_and_value
len =
else▼
len = len + #key_and_value▼
end
table.insert(JSON, key_and_value)
end
-- copied from [[wikt:Module:debug]]
function p.highlight(content, options)
if type(content) == "table" then
options = content
options = {
inline = options.inline and true
▲ }
return function(content)
return mw.getCurrentFrame():extensionTag{
name = "syntaxhighlight",
content = content,
args = options
▲ }
▲ return mw.getCurrentFrame():extensionTag{
▲ name = "syntaxhighlight",
▲ args = {
lang = options and options.lang or "lua",
inline = options and options.inline and true or nil
}
}
▲ end
-- Usage:
-- {{#invoke:Sandbox/Erutuon/charinsert_names|highlighted_character_names|abc}}
-- ↓
-- {"97":"LATIN SMALL LETTER A","98":"LATIN SMALL LETTER B",
-- "99":"LATIN SMALL LETTER C"}
function p.highlighted_character_names(frame)
local chars = frame.args[1]
if not chars or chars == "" then
error("Supply characters in parameter 1")
end
return p.highlight(p.JSON_character_names(chars))
end
function p.charinsert_char_names()
▲ local content = mw.title.new("MediaWiki:Gadget-charinsert-core.js"):getContent()
▲ local charinsert = content:match("charinsert: (%b{})")
▲ if not charinsert then return "Could not find charinsert" end
return p.highlight(p.JSON_character_names(charinsert))
end
|