summaryrefslogtreecommitdiff
path: root/tex/context/third/transliterator/trans_tables_iso9.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/third/transliterator/trans_tables_iso9.lua')
-rw-r--r--tex/context/third/transliterator/trans_tables_iso9.lua55
1 files changed, 38 insertions, 17 deletions
diff --git a/tex/context/third/transliterator/trans_tables_iso9.lua b/tex/context/third/transliterator/trans_tables_iso9.lua
index 5f7c6d8..256d994 100644
--- a/tex/context/third/transliterator/trans_tables_iso9.lua
+++ b/tex/context/third/transliterator/trans_tables_iso9.lua
@@ -2,7 +2,9 @@
-- ISO 9.1995(E) standardized transliteration for cyrillic --
--===========================================================================--
-local translit = thirddata.translit
+local translit = thirddata.translit
+local pcache = translit.parser_cache
+local lpegmatch = lpeg.match
if not translit.done_iso9 then
-----------------------------------------
@@ -110,10 +112,10 @@ if not translit.done_iso9 then
}
translit.ru_jer_hack = translit.make_add_dict{
- ["ь"] = "'",
- ["Ь"] = "'",
- ["ъ"] = "''",
- ["Ъ"] = "''",
+ ["ь"] = "’",
+ ["Ь"] = "’",
+ ["ъ"] = "”",
+ ["Ъ"] = "”",
}
translit.tables["russian magkij / tverdyj znak hack"] = translit.ru_jer_hack
@@ -252,8 +254,7 @@ end
-- End Of Tables --
--===========================================================================--
-
-local function iso9 (mode, text)
+local function iso9 (mode)
local P, R, S, V, Cs = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.Cs
local addrules = translit.addrules
local utfchar = translit.utfchar
@@ -270,20 +271,40 @@ local function iso9 (mode, text)
+ translit.non_ru_upp
+ translit.non_ru_low
end
- elseif mode == "ru_old_jer_hack" then
- iso9 = iso9
- + translit.ru_old_upp
- + translit.ru_old_low
- + translit.ru_jer_hack
+ if translit.deficient_font == "yes" then
+ iso9 = iso9
+ + translit.ru_old_upp
+ + translit.ru_old_low
+ + translit.ru_jer_hack
+ end
end
local p_iso9 = addrules (iso9, p_iso9)
local iso9_parser = Cs((p_iso9 / iso9 + utfchar)^0)
- return iso9_parser:match(text)
+ return iso9_parser
+end
+
+translit.methods["all"] = function (text)
+ local pname = "all" .. translit.deficient_font
+ local p = pcache[pname]
+ if not p then
+ p = iso9("all")
+ pcache[pname] = p
+ end
+ return lpegmatch(p, text)
+end
+
+translit.methods["ru"] = translit.methods["all"]
+
+translit.methods["ru_old"] = function (text)
+ local pname = "ru_old" .. translit.deficient_font
+ local p = pcache[pname]
+ if not p then
+ p = iso9("all")
+ pcache[pname] = p
+ end
+ return lpegmatch(p, text)
end
-translit.methods ["ru"] = function (text) return iso9 ("all" , text) end
-translit.methods ["all"] = function (text) return iso9 ("all" , text) end
-translit.methods ["ru_old"] = function (text) return iso9 ("ru_old" , text) end
-translit.methods ["ru_old_jer_hack"] = function (text) return iso9 ("ru_old_jer_hack", text) end
+-- vim:ft=lua:sw=4:ts=4