aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arabluatex.lua22
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)
35end 35end
36 36
37-- makeatletter, makeatother
38local atletter = "\\makeatletter{}"
39local atother = "\\makeatother{}"
40
37-- some basic patterns: 41-- some basic patterns:
38local ascii = lpeg.R("az", "AZ", "@@") 42local ascii = lpeg.R("az", "AZ", "@@")
39local dblbkslash = lpeg.Cs("\\") 43local dblbkslash = lpeg.Cs("\\")
@@ -229,7 +233,23 @@ local function takeoutcapetc(str)
229 return str 233 return str
230end 234end
231 235
236local 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
249end
250
232local function takeoutarb(str) 251local 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
726function processarbmarks(str) 746function 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