diff options
author | Robert Alessi <alessi@robertalessi.net> | 2019-02-16 11:58:55 +0100 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2019-02-16 11:58:55 +0100 |
commit | 80d0376fefbf90ecfb5204637fb53289c0030a6b (patch) | |
tree | d1d38b987c60c401ab6f0651d958df8581e7615b | |
parent | bf6055c05178e7146ab842e9471b2c3d5a4afd15 (diff) | |
download | arabluatex-80d0376fefbf90ecfb5204637fb53289c0030a6b.tar.gz |
export to utf: removing superfluous spaces needed a recursion
-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) |