diff options
-rw-r--r-- | arabluatex.lua | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/arabluatex.lua b/arabluatex.lua index b99fbca..f6110f9 100644 --- a/arabluatex.lua +++ b/arabluatex.lua | |||
@@ -53,12 +53,15 @@ local function unprotectarb(str) | |||
53 | return str | 53 | return str |
54 | end | 54 | end |
55 | 55 | ||
56 | -- 'albrkcmds' is what is set by default. 'brkcmds' is what may be | 56 | -- commands the arguments of which must not be processed by |
57 | -- set in the preamble as argument of \MkArbBreak{} | 57 | -- arabluatex. 'albrkcmds' is what is set by default. 'brkcmds' is |
58 | -- what may be set in the preamble as argument of \MkArbBreak{} | ||
58 | local albrkcmds = { | 59 | local albrkcmds = { |
59 | "Footnote", | 60 | "Footnote", |
60 | "Marginpar", | 61 | "Marginpar", |
61 | "edtext", | 62 | "edtext", |
63 | "pstart", | ||
64 | "pend", | ||
62 | "arbmark" | 65 | "arbmark" |
63 | } | 66 | } |
64 | local brkcmds = {} | 67 | local brkcmds = {} |
@@ -79,20 +82,21 @@ end | |||
79 | local dblbkslash = lpeg.Cs("\\") | 82 | local dblbkslash = lpeg.Cs("\\") |
80 | local bsqbrackets = lpeg.Cs{ "[" * ((1 - lpeg.S"[]") + lpeg.V(1))^0 * "]" } | 83 | local bsqbrackets = lpeg.Cs{ "[" * ((1 - lpeg.S"[]") + lpeg.V(1))^0 * "]" } |
81 | local bcbraces = lpeg.Cs{ "{" * ((1 - lpeg.S"{}") + lpeg.V(1))^0 * "}" } | 84 | local bcbraces = lpeg.Cs{ "{" * ((1 - lpeg.S"{}") + lpeg.V(1))^0 * "}" } |
82 | local spce = lpeg.P(" ") | 85 | local spce = lpeg.Cs(" ") |
83 | local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) | 86 | local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) |
84 | local bcbracesii = lpeg.Cs(bcbraces * bcbraces^-1) | 87 | local bcbracesii = lpeg.Cs(bcbraces^-2) |
88 | local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii) | ||
85 | 89 | ||
86 | local function breakcmd(str) | 90 | local function breakcmd(str) |
87 | for i = 1,#albrkcmds do | 91 | for i = 1,#albrkcmds do |
88 | str = gsub(str, dblbkslash * lpeg.Cs(albrkcmds[i]) * spce^-1 * bsqbracketsii * bcbracesii, "}%1%2%3%4\\arb{") | 92 | str = gsub(str, dblbkslash * lpeg.Cs(albrkcmds[i]) * cmdargs, "}%1%2%3\\arb{") |
89 | end | 93 | end |
90 | -- user commands | 94 | -- user commands |
91 | if next(brkcmds) == nil then | 95 | if next(brkcmds) == nil then |
92 | -- nothing to do | 96 | -- nothing to do |
93 | else | 97 | else |
94 | for i = 1,#brkcmds do | 98 | for i = 1,#brkcmds do |
95 | str = gsub(str, dblbkslash * lpeg.Cs(brkcmds[i]) * spce^-1 * bsqbracketsii * bcbracesii, "}%1%2%3%4\\arb{") | 99 | str = gsub(str, dblbkslash * lpeg.Cs(brkcmds[i]) * cmdargs, "}%1%2%3\\arb{") |
96 | end | 100 | end |
97 | end | 101 | end |
98 | -- process \item[], then \item | 102 | -- process \item[], then \item |