aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2018-05-28 18:05:12 +0200
committerRobert Alessi <alessi@robertalessi.net>2018-05-28 18:05:12 +0200
commitd25d0378431299c184512fa1958bfc0ec9f18cb2 (patch)
tree725bba517ca7214e420497da3c7773f65527814c
parent3f1f2d11ce0b89e7084905c4a0111b7d84455a60 (diff)
downloadarabluatex-d25d0378431299c184512fa1958bfc0ec9f18cb2.tar.gz
commands with no argument are now processed by \MkArbBreak{}. added \pstart and \pend to 'albrkcmds'
-rw-r--r--arabluatex.lua16
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)
53return str 53return str
54end 54end
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{}
58local albrkcmds = { 59local albrkcmds = {
59 "Footnote", 60 "Footnote",
60 "Marginpar", 61 "Marginpar",
61 "edtext", 62 "edtext",
63 "pstart",
64 "pend",
62 "arbmark" 65 "arbmark"
63} 66}
64local brkcmds = {} 67local brkcmds = {}
@@ -79,20 +82,21 @@ end
79local dblbkslash = lpeg.Cs("\\") 82local dblbkslash = lpeg.Cs("\\")
80local bsqbrackets = lpeg.Cs{ "[" * ((1 - lpeg.S"[]") + lpeg.V(1))^0 * "]" } 83local bsqbrackets = lpeg.Cs{ "[" * ((1 - lpeg.S"[]") + lpeg.V(1))^0 * "]" }
81local bcbraces = lpeg.Cs{ "{" * ((1 - lpeg.S"{}") + lpeg.V(1))^0 * "}" } 84local bcbraces = lpeg.Cs{ "{" * ((1 - lpeg.S"{}") + lpeg.V(1))^0 * "}" }
82local spce = lpeg.P(" ") 85local spce = lpeg.Cs(" ")
83local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) 86local bsqbracketsii = lpeg.Cs(bsqbrackets^-2)
84local bcbracesii = lpeg.Cs(bcbraces * bcbraces^-1) 87local bcbracesii = lpeg.Cs(bcbraces^-2)
88local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii)
85 89
86local function breakcmd(str) 90local 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