summaryrefslogtreecommitdiff
path: root/tex/context/base/char-utf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/char-utf.lua')
-rw-r--r--tex/context/base/char-utf.lua38
1 files changed, 35 insertions, 3 deletions
diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua
index ae81073bf..fcb8804dd 100644
--- a/tex/context/base/char-utf.lua
+++ b/tex/context/base/char-utf.lua
@@ -42,7 +42,6 @@ input.filters.utf_translator = characters.filters.utf.collapse
function characters.filters.utf.initialize()
if characters.filters.utf.collapsing and not characters.filters.utf.initialized then
- characters.graphemes = { }
local cg = characters.graphemes
local uc = utf.char
for k,v in pairs(characters.data) do
@@ -62,6 +61,39 @@ function characters.filters.utf.initialize()
end
end
+-- characters.filters.utf.add_grapheme(utf.char(318),'l','\string~')
+-- characters.filters.utf.add_grapheme('c','a','b')
+
+--~ function characters.filters.utf.add_grapheme(result,...)
+--~ local cg = characters.graphemes
+--~ local t = {...}
+--~ local n = table.getn(t)
+--~ for i=1,n do
+--~ local v = t[i]
+--~ if not cg[v] then
+--~ cg[v] = { }
+--~ end
+--~ if i == n then
+--~ cg[v] = result
+--~ else
+--~ cg = cg[v]
+--~ end
+--~ end
+--~ end
+
+function characters.filters.utf.add_grapheme(result,first,second)
+ local cg, uc = characters.graphemes, utf.char
+ local r, f, s = tonumber(result), tonumber(first), tonumber(second)
+ if r then result = uc(r) end
+ if f then first = uc(f) end
+ if s then second = uc(s) end
+ if not cg[first] then
+ cg[first] = { [second] = result }
+ else
+ cg[first][second] = result
+ end
+end
+
function characters.filters.utf.collapse(str) -- old one
if characters.filters.utf.collapsing and str and #str > 1 then
if not characters.filters.utf.initialized then -- saves a call
@@ -230,7 +262,7 @@ do
else
if cr[second] then
for s in su(str) do
- if n == 0 then
+ if n == 1 then
break
else
tokens[#tokens+1], n = s, n - 1
@@ -244,7 +276,7 @@ do
local cgf = cg[first]
if cgf and cgf[second] then
for s in su(str) do
- if n == 0 then
+ if n == 1 then
break
else
tokens[#tokens+1], n = s, n -1