summaryrefslogtreecommitdiff
path: root/tex/context/third/transliterator/trans_tables_scntfc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/third/transliterator/trans_tables_scntfc.lua')
-rw-r--r--tex/context/third/transliterator/trans_tables_scntfc.lua43
1 files changed, 35 insertions, 8 deletions
diff --git a/tex/context/third/transliterator/trans_tables_scntfc.lua b/tex/context/third/transliterator/trans_tables_scntfc.lua
index 904db71..ac5c398 100644
--- a/tex/context/third/transliterator/trans_tables_scntfc.lua
+++ b/tex/context/third/transliterator/trans_tables_scntfc.lua
@@ -2,7 +2,9 @@
-- Other transliterations --
--===========================================================================--
-local translit = thirddata.translit
+local translit = thirddata.translit
+local pcache = translit.parser_cache
+local lpegmatch = lpeg.match
-- The following are needed because ISO 9 does not cover old Slavonic
-- characters that became obsolete before the advent of гражданский шрифт.
@@ -201,7 +203,7 @@ end
-- End Of Tables --
--===========================================================================--
-local function scientific (mode, text)
+local function scientific (mode)
local P, Cs = lpeg.P, lpeg.Cs
local utfchar = translit.utfchar
local addrules = translit.addrules
@@ -221,7 +223,7 @@ local function scientific (mode, text)
+ translit.ocs_add_low
+ translit.ocs_add_upp
- if mode == "iso9_ocs_hack" then
+ if translit.deficient_font == "yes" then
cyr = cyr + translit.ru_jer_hack
end
@@ -248,11 +250,36 @@ local function scientific (mode, text)
scientific_parser = Cs((p_cyr / cyr + utfchar)^0)
end
- return scientific_parser:match(text)
+ return scientific_parser
end
-translit.methods ["iso9_ocs"] = function (text) return scientific( "iso9_ocs" , text ) end
-translit.methods ["iso9_ocs_hack"] = function (text) return scientific( "iso9_ocs_hack", text ) end
-translit.methods ["ocs"] = function (text) return scientific( "ocs" , text ) end
-translit.methods ["ocs_gla"] = function (text) return scientific( "ocs_gla" , text ) end
+translit.methods["iso9_ocs"] = function (text)
+ local pname = "iso9_ocs" .. translit.deficient_font
+ local p = pcache[pname]
+ if not p then
+ p = scientific("iso9_ocs")
+ pcache[pname] = p
+ end
+ return lpegmatch(p, text)
+end
+
+translit.methods["ocs"] = function (text)
+ local p = pcache["ocs"]
+ if not p then
+ p = scientific("ocs")
+ pcache["ocs"] = p
+ end
+ return lpegmatch(p, text)
+end
+
+translit.methods["ocs_gla"] = function (text)
+ local p = pcache["ocs_gla"]
+ if not p then
+ p = scientific("ocs_gla")
+ pcache["ocs_gla"] = p
+ end
+ return lpegmatch(p, text)
+end
+
+-- vim:ft=lua:ts=4:sw=4