Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Erutuon/charinsert names
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local function get_all_codepoints(str) local codepoint_set = {} for codepoint in mw.ustring.gcodepoint(str) do codepoint_set[codepoint] = true end return require "Module:TableTools".keysToList(codepoint_set) end 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 local key_and_value = '"' .. codepoint .. '":"' .. Unicode.lookup_name(codepoint) .. '"' local added_len = #key_and_value + 1 -- for comma if len + added_len > 79 then key_and_value = '\n' .. key_and_value len = 0 end len = len + added_len table.insert(JSON, key_and_value) end return "{" .. table.concat(JSON, ",") .. "}" end -- copied from [[wikt:Module:debug]] function p.highlight(content, options) if type(content) == "table" then options = content options = { lang = options.lang or "lua", inline = options.inline and true } return function(content) return mw.getCurrentFrame():extensionTag{ name = "syntaxhighlight", content = content, args = options } end else return mw.getCurrentFrame():extensionTag{ name = "syntaxhighlight", content = content, args = { lang = options and options.lang or "lua", inline = options and options.inline and true or nil } } end 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 return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
MediaWiki:Gadget-charinsert-core.js
(
view source
)
Module:Sandbox/Erutuon/charinsert names
(
edit
)
Module:Sandbox/Erutuon/charinsert names/doc
(
edit
)