From 6565f523e31cc7befbd7b473a2e9bc006559ad6c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 10 May 2011 14:35:41 +0200 Subject: improved Serbian exception handling --- tex/context/third/transliterator/trans_tables_sr.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'tex') diff --git a/tex/context/third/transliterator/trans_tables_sr.lua b/tex/context/third/transliterator/trans_tables_sr.lua index 0a601e3..0f9eae4 100644 --- a/tex/context/third/transliterator/trans_tables_sr.lua +++ b/tex/context/third/transliterator/trans_tables_sr.lua @@ -91,16 +91,25 @@ if not translit.done_serbian then translit.sr_tocy_lower = translit.make_add_dict(__inverse_tab(translit.sr_tolt_lower)) translit.sr_tocy_upper = translit.make_add_dict(__inverse_tab(translit.sr_tolt_upper)) - translit.serbian_exceptions = { + local except = { ["nadživeti"] = "надживети", - ["Nadživeti"] = "Надживети", } local P = lpeg.P - for lat, _ in next, translit.serbian_exceptions do - translit.p_serbian_exceptions = translit.p_serbian_exceptions and translit.p_serbian_exceptions + P(lat) or P(lat) + local sub, upper = unicode.utf8.sub, unicode.utf8.upper + + local sre, p_sre = {} + for lat, cyr in next, except do + local Lat = upper(sub(lat, 1, 1)) .. sub(lat, 2) + local Cyr = upper(sub(cyr, 1, 1)) .. sub(cyr, 2) + local LAT, CYR = upper(lat), upper(cyr) + p_sre = p_sre and p_sre + P(lat) + Lat + LAT or P(lat) + Lat + LAT + sre[lat], sre[Lat], sre[LAT] = cyr, Cyr, CYR end + translit.serbian_exceptions = sre + translit.p_serbian_exceptions = p_sre + translit.done_serbian = true end -- cgit v1.2.3