From 80d0376fefbf90ecfb5204637fb53289c0030a6b Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sat, 16 Feb 2019 11:58:55 +0100 Subject: export to utf: removing superfluous spaces needed a recursion --- arabluatex.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arabluatex.lua b/arabluatex.lua index 435519c..292c01c 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -823,6 +823,15 @@ function tooutfile(str, nl) return str end +local function removespaceaftercmd(str) + str = gsub(str, cmd * spce^1 * bsqbracketsii * bcbraces, function(cmd, space, brackets, braces) + braces = string.sub(braces, 2, -2) + braces = removespaceaftercmd(braces) + return string.format("%s%s{%s}", cmd, brackets, braces) + end) + return str +end + function al_closestream() local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") local o = io.open(tex.jobname..utffilesuffix..".tex", "w") @@ -870,7 +879,7 @@ function al_closestream() [[ and compile it one more time}}]]) -- else end - t = gsub(t, cmd * spce * cmdargs, "%1%3") + t = removespaceaftercmd(t) t = t.."\n\\end{document}" io.write(t) o:write(t) -- cgit v1.2.3