aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arabluatex.lua28
1 files changed, 21 insertions, 7 deletions
diff --git a/arabluatex.lua b/arabluatex.lua
index ec318b7..3d6ec80 100644
--- a/arabluatex.lua
+++ b/arabluatex.lua
@@ -59,6 +59,20 @@ local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces)
59local arind = lpeg.Cs(dblbkslash * lpeg.P("arind") * spce^-1 * bsqbracketsii) 59local arind = lpeg.Cs(dblbkslash * lpeg.P("arind") * spce^-1 * bsqbracketsii)
60 60
61local function protectarb(str) 61local function protectarb(str)
62 -- \App[]{}{}
63 str = string.gsub(str, "(\\App%s?)(%b{})(%b{})", "%1[]%2%3")
64 str = gsub(str, lpeg.P("\\App") * spcenc^-1 * bsqbrackets * bcbraces * bcbraces,
65 function(opt, lem, rdg)
66 opt = string.sub(opt, 2, -2)
67 lem = string.sub(lem, 2, -2)
68 rdg = string.sub(rdg, 2, -2)
69 if opt == ""
70 then
71 return string.format("\\app{%s%s}", lem, rdg)
72 else
73 return string.format("\\app[%s]{%s%s}", opt, lem, rdg)
74 end
75 end)
62 str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") 76 str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}")
63 str = string.gsub(str, "(\\LR%s?)(%b{})", "\\@LR%2") 77 str = string.gsub(str, "(\\LR%s?)(%b{})", "\\@LR%2")
64 str = string.gsub(str, "(\\RL%s?)(%b{})", "\\@RL%2") 78 str = string.gsub(str, "(\\RL%s?)(%b{})", "\\@RL%2")
@@ -121,14 +135,14 @@ end
121 135
122local function breakcmd(str) 136local function breakcmd(str)
123 -- \par 137 -- \par
124 str = gsub(str, dblbkslash * lpeg.Cs("par") * cmdargsnobs, "\\al@brk{%1%2%3}") 138 str = gsub(str, dblbkslash * lpeg.Cs("par") * cmdargsnobs, "\\al@brk{%1%2%3}")
125 -- process \item[], then \item[] 139 -- process \item[], then \item[]
126 str = string.gsub(str, "\\(item.?)(%b[])", 140 str = string.gsub(str, "\\(item.?)(%b[])",
127 function(tag, body) 141 function(tag, body)
128 body = string.sub(body, 2, -2) 142 body = string.sub(body, 2, -2)
129 return string.format("\\al@brk{\\item[\\arb{%s}] }", body) 143 return string.format("\\al@brk{\\item[\\arb{%s}] }", body)
130 end) 144 end)
131 str = string.gsub(str, "(\\item)(%s+)", "%1{}%2") 145 str = string.gsub(str, "(\\item)(%s+)", "%1{}%2")
132 -- \textcolor 146 -- \textcolor
133 str = string.gsub(str, "\\(textcolor%s?)(%b{})(%b{})", 147 str = string.gsub(str, "\\(textcolor%s?)(%b{})(%b{})",
134 function(tag, bodycolor, bodytext) 148 function(tag, bodycolor, bodytext)