diff options
Diffstat (limited to 'tex/context/third/transliterator/trans_tables_gr.lua')
-rw-r--r-- | tex/context/third/transliterator/trans_tables_gr.lua | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/tex/context/third/transliterator/trans_tables_gr.lua b/tex/context/third/transliterator/trans_tables_gr.lua index 55b4c54..b4c77e7 100644 --- a/tex/context/third/transliterator/trans_tables_gr.lua +++ b/tex/context/third/transliterator/trans_tables_gr.lua @@ -2,7 +2,9 @@ -- Greek -- --===========================================================================-- -local translit = thirddata.translit +local translit = thirddata.translit +local pcache = translit.parser_cache +local lpegmatch = lpeg.match -- Note that the Greek transliteration mapping isn't bijective so transliterated -- texts won't be reversible. (Shouldn't be impossible to make one up using @@ -682,11 +684,26 @@ local function greek (mode, text) other = Cs(p / gr ), } - --g:print() - text = g:match(text) - return text + return g end end -translit.methods ["gr"] = function (text) return greek("gr" , text) end -translit.methods ["gr_n"] = function (text) return greek("gr_n", text) end +translit.methods["gr"] = function (text) + p = pcache["gr"] + if not p then + p = greek("gr") + pcache["gr"] = p + end + return lpegmatch(p, text) +end + +translit.methods["gr_n"] = function (text) + p = pcache["gr_n"] + if not p then + p = greek("gr_n") + pcache["gr_n"] = p + end + return lpegmatch(p, text) +end + +-- vim:ft=lua:sw=4:ts=4 |