summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/char-ini.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-04-20 22:56:41 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-04-20 22:56:41 +0200
commitf2a20e191bf71094aa21d37dee2ecd2f804dbc56 (patch)
tree5c94b5e2d5c0ec7e1946bf967a982c27f99a5fdc /tex/context/base/mkiv/char-ini.lua
parent218228536ed709be8ab2dde4a00dc27249ceed8a (diff)
downloadcontext-f2a20e191bf71094aa21d37dee2ecd2f804dbc56.tar.gz
2017-04-20 21:37:00
Diffstat (limited to 'tex/context/base/mkiv/char-ini.lua')
-rw-r--r--tex/context/base/mkiv/char-ini.lua25
1 files changed, 23 insertions, 2 deletions
diff --git a/tex/context/base/mkiv/char-ini.lua b/tex/context/base/mkiv/char-ini.lua
index a9ea52cce..3cebeabd9 100644
--- a/tex/context/base/mkiv/char-ini.lua
+++ b/tex/context/base/mkiv/char-ini.lua
@@ -14,7 +14,7 @@ if not modules then modules = { } end modules ['char-ini'] = {
local utfchar, utfbyte, utfvalues, ustring, utotable = utf.char, utf.byte, utf.values, utf.ustring, utf.totable
local concat, unpack, tohash, insert = table.concat, table.unpack, table.tohash, table.insert
local next, tonumber, type, rawget, rawset = next, tonumber, type, rawget, rawset
-local format, lower, gsub = string.format, string.lower, string.gsub
+local format, lower, gsub, find = string.format, string.lower, string.gsub, string.find
local P, R, S, Cs = lpeg.P, lpeg.R, lpeg.S, lpeg.Cs
if not characters then require("char-def") end
@@ -942,6 +942,7 @@ end)
local specialchars = allocate() characters.specialchars = specialchars -- lazy table
local descriptions = allocate() characters.descriptions = descriptions -- lazy table
+local synonyms = allocate() characters.synonyms = synonyms -- lazy table
setmetatableindex(specialchars, function(t,u)
if u then
@@ -975,7 +976,9 @@ setmetatableindex(descriptions, function(t,k)
for u, c in next, data do
local d = c.description
if d then
- d = gsub(d," ","")
+ if find(d," ") then
+ d = gsub(d," ","")
+ end
d = lower(d)
t[d] = u
end
@@ -987,6 +990,24 @@ setmetatableindex(descriptions, function(t,k)
return d
end)
+setmetatableindex(synonyms, function(t,k)
+ for u, c in next, data do
+ local s = c.synonyms
+ if s then
+ if find(s," ") then
+ s = gsub(s," ","")
+ end
+ -- s = lower(s) -- is already lowercase
+ t[s] = u
+ end
+ end
+ local s = rawget(t,k)
+ if not s then
+ t[s] = s
+ end
+ return s
+end)
+
function characters.unicodechar(asked)
local n = tonumber(asked)
if n then