From c05933f3664e3ea91bf0ec0191651282c284a1b5 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Tue, 2 Oct 2018 14:21:07 +0200 Subject: a bit of tidy up --- arabluatex.lua | 17 +++++++++++------ 1 file 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() t = string.gsub(t, "(\\@al@ob)", "{") t = string.gsub(t, "(\\@al@cb@sp)", "} ") t = string.gsub(t, "(\\@al@cb)(%s?)", "}") - t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, "\n%1%2%3\n") + t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, + "\n%1%2%3\n") t = string.gsub(t, "(\\\\)(%s?)", "%1\n") t = string.gsub(t, "(\\\\)(\n)(\\end%s?)(%b{})", "%1%3%4") t = string.gsub(t, "%s-\n(\\begin%s?)(%b{})", "\n%1%2") @@ -822,21 +823,25 @@ function al_closestream() t = string.gsub(t, "(\\end%s?)(%b{})", "%1%2\n") t = string.gsub(t, "([^\n]%s-)(\\end)%s?(%b{})", "%1\n%2%3") t = string.gsub(t, "\n\n\n", "\n\n") - t = string.gsub(t, "(\\txarb%s?%{)(\\txarb%s?)(%b{})(%})", function(tagio, tagii, body, tagic) + t = string.gsub(t, "(\\txarb%s?%{)(\\txarb%s?)(%b{})(%})", + function(tagio, tagii, body, tagic) body = string.sub(body, 2, -2) - return string.format("%s%s%s", tagio, body, tagic) + return + string.format("%s%s%s", tagio, body, tagic) end) - t = string.gsub(t, "(\\prname%s?%*%{)(\\txtrans%s?)(%b{})(%})", function(tagio, tagii, body, tagic) + t = string.gsub(t, "(\\prname%s?%*%{)(\\txtrans%s?)(%b{})(%})", + function(tagio, tagii, body, tagic) body = string.sub(body, 2, -2) return string.format("%s%s%s", tagio, body, tagic) end) - if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") or + if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") + or string.find(t, "\\begin%s?{document}.-\\[Uu]c%s?%b{}") then tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{ There are still 'arabtex' strings to be converted. Please open ]] .. tex.jobname .. utffilesuffix .. ".tex" .. - [[ and compile it one more time}}]]) + [[ and compile it one more time}}]]) else end t = t.."\n\\end{document}" io.write(t) -- cgit v1.2.3