aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-02-16 11:58:55 +0100
committerRobert Alessi <alessi@robertalessi.net>2019-02-16 11:58:55 +0100
commit80d0376fefbf90ecfb5204637fb53289c0030a6b (patch)
treed1d38b987c60c401ab6f0651d958df8581e7615b
parentbf6055c05178e7146ab842e9471b2c3d5a4afd15 (diff)
downloadarabluatex-80d0376fefbf90ecfb5204637fb53289c0030a6b.tar.gz
export to utf: removing superfluous spaces needed a recursion
-rw-r--r--arabluatex.lua11
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
824end 824end
825 825
826local 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
833end
834
826function al_closestream() 835function 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)