aboutsummaryrefslogtreecommitdiff
path: root/arabluatex.lua
diff options
context:
space:
mode:
Diffstat (limited to 'arabluatex.lua')
-rw-r--r--arabluatex.lua13
1 files changed, 3 insertions, 10 deletions
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("*"))
49local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) 49local bsqbracketsii = lpeg.Cs(bsqbrackets^-2)
50local bcbracesii = lpeg.Cs(bcbraces^-2) 50local bcbracesii = lpeg.Cs(bcbraces^-2)
51local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) 51local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1)
52local rawcmd = lpeg.Cs(dblbkslash * ascii^1)
53local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash)
52local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) 54local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1)
53local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) 55local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces)
54local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) 56local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces)
@@ -823,15 +825,6 @@ function tooutfile(str, nl)
823 return str 825 return str
824end 826end
825 827
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
835function al_closestream() 828function al_closestream()
836 local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") 829 local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r")
837 local o = io.open(tex.jobname..utffilesuffix..".tex", "w") 830 local o = io.open(tex.jobname..utffilesuffix..".tex", "w")
@@ -879,7 +872,7 @@ function al_closestream()
879 [[ and compile it one more time}}]]) 872 [[ and compile it one more time}}]])
880 -- 873 --
881 else end 874 else end
882 t = removespaceaftercmd(t) 875 t = gsub(t, rawcmd * spce^1 * aftercmd, "%1%3")
883 t = t.."\n\\end{document}" 876 t = t.."\n\\end{document}"
884 io.write(t) 877 io.write(t)
885 o:write(t) 878 o:write(t)