diff options
author | Robert Alessi <alessi@robertalessi.net> | 2019-02-16 20:02:27 +0100 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2019-02-16 20:02:27 +0100 |
commit | 364e7a86bf391a4d382d1e6d21eaeef873c5bb55 (patch) | |
tree | 0d7b3916bf1278f56df39d5d6822bc907eabf9af | |
parent | 80d0376fefbf90ecfb5204637fb53289c0030a6b (diff) | |
download | arabluatex-364e7a86bf391a4d382d1e6d21eaeef873c5bb55.tar.gz |
[80d0376]: in the end, no recursion was needed
-rw-r--r-- | arabluatex.dtx | 1 | ||||
-rw-r--r-- | arabluatex.lua | 13 |
2 files changed, 4 insertions, 10 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx index 6ec43b0..839d4a8 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx | |||
@@ -2811,6 +2811,7 @@ word that \cs{arbnull} is applied to. | |||
2811 | % 'a`\arbcolor[red]{^g}.aba-ka}. | 2811 | % 'a`\arbcolor[red]{^g}.aba-ka}. |
2812 | % | 2812 | % |
2813 | % |i^staraytu-hu| |bi-_tama\arbcolor[red]{n}\arbcolor[blue]{iN}| | 2813 | % |i^staraytu-hu| |bi-_tama\arbcolor[red]{n}\arbcolor[blue]{iN}| |
2814 | % \allowbreak | ||
2814 | % |'a`\arbcolor[red]|\allowbreak|{^g}\arbcolor[blue]{.a}ba-ka| | 2815 | % |'a`\arbcolor[red]|\allowbreak|{^g}\arbcolor[blue]{.a}ba-ka| |
2815 | % \arb{i^staraytu-hu bi-_tama\arbcolor[red]{n}\arbcolor[blue]{iN} | 2816 | % \arb{i^staraytu-hu bi-_tama\arbcolor[red]{n}\arbcolor[blue]{iN} |
2816 | % 'a`\arbcolor[red]{^g}\arbcolor[blue]{.a}ba-ka} \linebreak | 2817 | % 'a`\arbcolor[red]{^g}\arbcolor[blue]{.a}ba-ka} \linebreak |
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("*")) | |||
49 | local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) | 49 | local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) |
50 | local bcbracesii = lpeg.Cs(bcbraces^-2) | 50 | local bcbracesii = lpeg.Cs(bcbraces^-2) |
51 | local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) | 51 | local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) |
52 | local rawcmd = lpeg.Cs(dblbkslash * ascii^1) | ||
53 | local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash) | ||
52 | local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) | 54 | local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) |
53 | local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) | 55 | local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) |
54 | local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) | 56 | local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) |
@@ -823,15 +825,6 @@ function tooutfile(str, nl) | |||
823 | return str | 825 | return str |
824 | end | 826 | end |
825 | 827 | ||
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 | |||
835 | function al_closestream() | 828 | function 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) |