diff options
-rw-r--r-- | arabluatex.lua | 11 |
1 files changed, 10 insertions, 1 deletions
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) | |||
823 | return str | 823 | return str |
824 | end | 824 | end |
825 | 825 | ||
826 | local function removespaceaftercmd(str) | ||
827 | str = gsub(str, cmd * spce^1 * bsqbracketsii * bcbraces, function(cmd, space, brackets, braces) | ||
828 | braces = string.sub(braces, 2, -2) | ||
829 | braces = removespaceaftercmd(braces) | ||
830 | return string.format("%s%s{%s}", cmd, brackets, braces) | ||
831 | end) | ||
832 | return str | ||
833 | end | ||
834 | |||
826 | function al_closestream() | 835 | function al_closestream() |
827 | local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") | 836 | local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") |
828 | local o = io.open(tex.jobname..utffilesuffix..".tex", "w") | 837 | local o = io.open(tex.jobname..utffilesuffix..".tex", "w") |
@@ -870,7 +879,7 @@ function al_closestream() | |||
870 | [[ and compile it one more time}}]]) | 879 | [[ and compile it one more time}}]]) |
871 | -- | 880 | -- |
872 | else end | 881 | else end |
873 | t = gsub(t, cmd * spce * cmdargs, "%1%3") | 882 | t = removespaceaftercmd(t) |
874 | t = t.."\n\\end{document}" | 883 | t = t.."\n\\end{document}" |
875 | io.write(t) | 884 | io.write(t) |
876 | o:write(t) | 885 | o:write(t) |