diff options
-rw-r--r-- | arabluatex.lua | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/arabluatex.lua b/arabluatex.lua index 4d135f3..11a91c3 100644 --- a/arabluatex.lua +++ b/arabluatex.lua | |||
@@ -34,6 +34,10 @@ local function gsub(s, patt, repl) | |||
34 | return lpeg.match(patt, s) | 34 | return lpeg.match(patt, s) |
35 | end | 35 | end |
36 | 36 | ||
37 | -- makeatletter, makeatother | ||
38 | local atletter = "\\makeatletter{}" | ||
39 | local atother = "\\makeatother{}" | ||
40 | |||
37 | -- some basic patterns: | 41 | -- some basic patterns: |
38 | local ascii = lpeg.R("az", "AZ", "@@") | 42 | local ascii = lpeg.R("az", "AZ", "@@") |
39 | local dblbkslash = lpeg.Cs("\\") | 43 | local dblbkslash = lpeg.Cs("\\") |
@@ -229,7 +233,23 @@ local function takeoutcapetc(str) | |||
229 | return str | 233 | return str |
230 | end | 234 | end |
231 | 235 | ||
236 | local function checkwrnested(str) | ||
237 | for i = 1,#outofarb do | ||
238 | str = gsub(str, dblbkslash * lpeg.Cs(lpeg.P("LR") + lpeg.P("RL")) * cmdargs, | ||
239 | function(prefix, tag, body) | ||
240 | body = string.sub(body, 2, -2) | ||
241 | if string.find(body, "\\"..outofarb[i]) then | ||
242 | return atletter.."\\al@wrong@nesting{}"..atother | ||
243 | else | ||
244 | -- nothing to do, so proceed. | ||
245 | end | ||
246 | end) | ||
247 | end | ||
248 | return str | ||
249 | end | ||
250 | |||
232 | local function takeoutarb(str) | 251 | local function takeoutarb(str) |
252 | str = checkwrnested(str) | ||
233 | for i = 1,#outofarb do | 253 | for i = 1,#outofarb do |
234 | str = gsub(str, dblbkslash * lpeg.Cs(outofarb[i]) * cmdargs, | 254 | str = gsub(str, dblbkslash * lpeg.Cs(outofarb[i]) * cmdargs, |
235 | function(prefix, tag, body) | 255 | function(prefix, tag, body) |
@@ -725,7 +745,7 @@ end | |||
725 | 745 | ||
726 | function processarbmarks(str) | 746 | function processarbmarks(str) |
727 | if not isintable(arbmarks, str) then | 747 | if not isintable(arbmarks, str) then |
728 | str = "\\LR{<??>}" | 748 | str = "\\LR{<??>}"..atletter.."\\al@wrong@mark{}"..atother |
729 | else | 749 | else |
730 | if tex.textdir == "TLT" then | 750 | if tex.textdir == "TLT" then |
731 | for i = 1,#arbmarks do | 751 | for i = 1,#arbmarks do |