From 364e7a86bf391a4d382d1e6d21eaeef873c5bb55 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sat, 16 Feb 2019 20:02:27 +0100 Subject: [80d0376]: in the end, no recursion was needed --- arabluatex.lua | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'arabluatex.lua') diff --git a/arabluatex.lua b/arabluatex.lua index 292c01c..9d83438 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -49,6 +49,8 @@ local cmdstar = lpeg.Cs(spce * lpeg.P("*")) local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) local bcbracesii = lpeg.Cs(bcbraces^-2) local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) +local rawcmd = lpeg.Cs(dblbkslash * ascii^1) +local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash) local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) @@ -823,15 +825,6 @@ 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") @@ -879,7 +872,7 @@ function al_closestream() [[ and compile it one more time}}]]) -- else end - t = removespaceaftercmd(t) + t = gsub(t, rawcmd * spce^1 * aftercmd, "%1%3") t = t.."\n\\end{document}" io.write(t) o:write(t) -- cgit v1.2.3