diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2015-05-16 00:15:04 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2015-05-16 00:15:04 +0200 |
commit | b55577d0998160c0174e250b542016ecd6ca9056 (patch) | |
tree | 27093212d5ca3e6ffe4ae434c3ec094233ed37ba /tex/context/base/m-translate.mkiv | |
parent | 624cbb5da392e9403984dd1cf368c0d408b1c2a8 (diff) | |
download | context-b55577d0998160c0174e250b542016ecd6ca9056.tar.gz |
2015-05-15 23:06:00
Diffstat (limited to 'tex/context/base/m-translate.mkiv')
-rw-r--r-- | tex/context/base/m-translate.mkiv | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tex/context/base/m-translate.mkiv b/tex/context/base/m-translate.mkiv index f36f9a9fb..2e6cbe950 100644 --- a/tex/context/base/m-translate.mkiv +++ b/tex/context/base/m-translate.mkiv @@ -22,12 +22,34 @@ local compiled, list = nil, nil + -- function translators.register(from,to) + -- local l = lpeg.P(from)/to + -- if not list then + -- list = l + -- else + -- list = list + l + -- end + -- compiled = nil + -- end + -- + -- function translators.translate(s) + -- if list then + -- if not compiled then + -- compiled = lpeg.Cs((list + lpeg.P(1))^0) + -- end + -- return compiled:match(s) + -- else + -- return s + -- end + -- end + + -- local function prepare() + function translators.register(from,to) - local l = lpeg.P(from)/to if not list then - list = l + list = { [from] = to } else - list = list + l + list[from] = to end compiled = nil end @@ -35,7 +57,8 @@ function translators.translate(s) if list then if not compiled then - compiled = lpeg.Cs((list + lpeg.P(1))^0) + local tree = lpeg.utfchartabletopattern(list) + compiled = lpeg.Cs((tree/list + lpeg.patterns.utf8character)^0 * lpeg.P(-1)) -- the P(1) is needed in order to accept non utf end return compiled:match(s) else |