aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arabluatex.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index ab92174..20f1ecf 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -813,7 +813,8 @@ function al_closestream()
813 t = string.gsub(t, "(\\@al@ob)", "{") 813 t = string.gsub(t, "(\\@al@ob)", "{")
814 t = string.gsub(t, "(\\@al@cb@sp)", "} ") 814 t = string.gsub(t, "(\\@al@cb@sp)", "} ")
815 t = string.gsub(t, "(\\@al@cb)(%s?)", "}") 815 t = string.gsub(t, "(\\@al@cb)(%s?)", "}")
816 t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, "\n%1%2%3\n") 816 t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs,
817 "\n%1%2%3\n")
817 t = string.gsub(t, "(\\\\)(%s?)", "%1\n") 818 t = string.gsub(t, "(\\\\)(%s?)", "%1\n")
818 t = string.gsub(t, "(\\\\)(\n)(\\end%s?)(%b{})", "%1%3%4") 819 t = string.gsub(t, "(\\\\)(\n)(\\end%s?)(%b{})", "%1%3%4")
819 t = string.gsub(t, "%s-\n(\\begin%s?)(%b{})", "\n%1%2") 820 t = string.gsub(t, "%s-\n(\\begin%s?)(%b{})", "\n%1%2")
@@ -822,21 +823,25 @@ function al_closestream()
822 t = string.gsub(t, "(\\end%s?)(%b{})", "%1%2\n") 823 t = string.gsub(t, "(\\end%s?)(%b{})", "%1%2\n")
823 t = string.gsub(t, "([^\n]%s-)(\\end)%s?(%b{})", "%1\n%2%3") 824 t = string.gsub(t, "([^\n]%s-)(\\end)%s?(%b{})", "%1\n%2%3")
824 t = string.gsub(t, "\n\n\n", "\n\n") 825 t = string.gsub(t, "\n\n\n", "\n\n")
825 t = string.gsub(t, "(\\txarb%s?%{)(\\txarb%s?)(%b{})(%})", function(tagio, tagii, body, tagic) 826 t = string.gsub(t, "(\\txarb%s?%{)(\\txarb%s?)(%b{})(%})",
827 function(tagio, tagii, body, tagic)
826 body = string.sub(body, 2, -2) 828 body = string.sub(body, 2, -2)
827 return string.format("%s%s%s", tagio, body, tagic) 829 return
830 string.format("%s%s%s", tagio, body, tagic)
828 end) 831 end)
829 t = string.gsub(t, "(\\prname%s?%*%{)(\\txtrans%s?)(%b{})(%})", function(tagio, tagii, body, tagic) 832 t = string.gsub(t, "(\\prname%s?%*%{)(\\txtrans%s?)(%b{})(%})",
833 function(tagio, tagii, body, tagic)
830 body = string.sub(body, 2, -2) 834 body = string.sub(body, 2, -2)
831 return string.format("%s%s%s", tagio, body, tagic) 835 return string.format("%s%s%s", tagio, body, tagic)
832 end) 836 end)
833 if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") or 837 if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]")
838 or
834 string.find(t, "\\begin%s?{document}.-\\[Uu]c%s?%b{}") 839 string.find(t, "\\begin%s?{document}.-\\[Uu]c%s?%b{}")
835 then 840 then
836 tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{ 841 tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{
837 There are still 'arabtex' strings to be converted. 842 There are still 'arabtex' strings to be converted.
838 Please open ]] .. tex.jobname .. utffilesuffix .. ".tex" .. 843 Please open ]] .. tex.jobname .. utffilesuffix .. ".tex" ..
839 [[ and compile it one more time}}]]) 844 [[ and compile it one more time}}]])
840 else end 845 else end
841 t = t.."\n\\end{document}" 846 t = t.."\n\\end{document}"
842 io.write(t) 847 io.write(t)