diff options
author | Robert Alessi <alessi@robertalessi.net> | 2018-08-12 12:22:51 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2018-08-12 12:22:51 +0200 |
commit | 136c4a8f6ce140ecf7325c0fb0a92dc4bb6464a9 (patch) | |
tree | 71395134ab604a8b67106ad06e3440d17f9e88d8 | |
parent | 5c6d0893befcc5ac8102d2fe9480f4be0046de68 (diff) | |
download | arabluatex-136c4a8f6ce140ecf7325c0fb0a92dc4bb6464a9.tar.gz |
better protection of \arb[]{} nested inside Arabic environments
-rw-r--r-- | arabluatex.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arabluatex.lua b/arabluatex.lua index 4128955..c0d9022 100644 --- a/arabluatex.lua +++ b/arabluatex.lua | |||
@@ -54,7 +54,8 @@ local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) | |||
54 | local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) | 54 | local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) |
55 | 55 | ||
56 | local function protectarb(str) | 56 | local function protectarb(str) |
57 | str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\@arb%2%3") | 57 | -- str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\@arb%2%3") |
58 | str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") | ||
58 | str = string.gsub(str, "(\\LR%s?)(%b{})", "\\@LR%2") | 59 | str = string.gsub(str, "(\\LR%s?)(%b{})", "\\@LR%2") |
59 | str = string.gsub(str, "(\\RL%s?)(%b{})", "\\@RL%2") | 60 | str = string.gsub(str, "(\\RL%s?)(%b{})", "\\@RL%2") |
60 | return str | 61 | return str |
@@ -670,6 +671,7 @@ function al_openstream() | |||
670 | end | 671 | end |
671 | 672 | ||
672 | local function processarbtoutf(str) | 673 | local function processarbtoutf(str) |
674 | str = "\n\\begin{arbexport}\n"..str | ||
673 | str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) | 675 | str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) |
674 | body = string.sub(body, 2, -2) | 676 | body = string.sub(body, 2, -2) |
675 | return string.format("\\arb[trans]{\\uc{%s}}", body) | 677 | return string.format("\\arb[trans]{\\uc{%s}}", body) |
@@ -707,6 +709,7 @@ local function processarbtoutf(str) | |||
707 | body = string.gsub(body, "\\@al@cb%s?", "}") | 709 | body = string.gsub(body, "\\@al@cb%s?", "}") |
708 | return string.format("{%s}", body) | 710 | return string.format("{%s}", body) |
709 | end) | 711 | end) |
712 | str = str.."\n\\end{arbexport}" | ||
710 | return str | 713 | return str |
711 | end | 714 | end |
712 | 715 | ||
@@ -784,7 +787,7 @@ function al_closestream() | |||
784 | t = string.gsub(t, "\\@al@ob%s?", "{") | 787 | t = string.gsub(t, "\\@al@ob%s?", "{") |
785 | t = string.gsub(t, "\\@al@cb", "}") | 788 | t = string.gsub(t, "\\@al@cb", "}") |
786 | t = string.gsub(t, "\n\n\n", "\n\n") | 789 | t = string.gsub(t, "\n\n\n", "\n\n") |
787 | if string.find(t, "\\begin%s?{document}.-\\arb") then | 790 | if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") then |
788 | tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) | 791 | tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) |
789 | else end | 792 | else end |
790 | t = t.."\n\\end{document}" | 793 | t = t.."\n\\end{document}" |