diff options
author | Robert Alessi <alessi@robertalessi.net> | 2018-06-01 10:35:11 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2018-06-01 10:35:11 +0200 |
commit | 9ed235c0bea637355cfa53222ae263cabc476ba8 (patch) | |
tree | 33d208e8dc22c721a652bb87391033c97f71c049 | |
parent | 009d8e35bc4401a7543037868c855e882d19e4ea (diff) | |
download | arabluatex-9ed235c0bea637355cfa53222ae263cabc476ba8.tar.gz |
breakcmd(): iteration through albrkcmds and brkcmds had to be moved down. still documenting
-rw-r--r-- | arabluatex.dtx | 34 | ||||
-rw-r--r-- | arabluatex.lua | 25 |
2 files changed, 39 insertions, 20 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx index 07f4f54..560405c 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx | |||
@@ -3213,10 +3213,10 @@ qAla barzawayhi bn-u 'azhar-a, ra's-u 'a.tibbA'-i fAris-a... | |||
3213 | % | 3213 | % |
3214 | % \DescribeMacro{\MkArbBreak} The \cs{MkArbBreak}\marg{csv list of | 3214 | % \DescribeMacro{\MkArbBreak} The \cs{MkArbBreak}\marg{csv list of |
3215 | % commands} command can be used in the preamble to give any | 3215 | % commands} command can be used in the preamble to give any |
3216 | % \emph{single-argument} command---either new or already | 3216 | % command---either new or already existing---the precedence over |
3217 | % existing---the precedence over \package{arabluatex} inside Arabic | 3217 | % \package{arabluatex} inside Arabic environments. It takes as |
3218 | % environments. It takes as argument a comma-separated list of | 3218 | % argument a comma-separated list of commands each of which must be |
3219 | % commands each of which must be stripped of its leading character | 3219 | % stripped of its leading character |
3220 | % |\|, like so:---\\ | 3220 | % |\|, like so:---\\ |
3221 | % \arabluaverb{\MkArbBreak{onecmd, anothercmd, yetanothercmd, ...}} | 3221 | % \arabluaverb{\MkArbBreak{onecmd, anothercmd, yetanothercmd, ...}} |
3222 | % | 3222 | % |
@@ -3240,6 +3240,24 @@ qAla barzawayhi bn-u 'azhar-a, ra's-u 'a.tibbA'-i fAris-a... | |||
3240 | %</example> | 3240 | %</example> |
3241 | % \fi | 3241 | % \fi |
3242 | % | 3242 | % |
3243 | % It must be noted that the arguments, either optional or mandatory, | ||
3244 | % of commands declared with \cs{MkArbBreak} are not to be processed by | ||
3245 | % \package{arabluatex}. Therefore, as in the previous example, any of | ||
3246 | % their argument to be rendered in Arabic must be inserted again in | ||
3247 | % \cs{arb}. \NEWfeature{v1.12}These commands themselves may have up to | ||
3248 | % two optional and/or mandatory arguments, like so:--- | ||
3249 | % \begin{compactenum}[(a)] | ||
3250 | % \item \cs{command} (no argument, lowermost combination) | ||
3251 | % \item \cs{command}\oarg{opt1} (one optional argument) | ||
3252 | % \item \cs{command}\marg{arg1} (one mandatory argument) | ||
3253 | % \item \cs{command}\oarg{opt1}\marg{arg1} (one optional and one | ||
3254 | % mandatory argument) | ||
3255 | % \item (\ldots) | ||
3256 | % \item \cs{command}\oarg{opt1}\oarg{opt2}\marg{arg1}\marg{arg2} | ||
3257 | % (uppermost combination) | ||
3258 | % \end{compactenum} | ||
3259 | % | ||
3260 | % | ||
3243 | % \subsection{Environments} | 3261 | % \subsection{Environments} |
3244 | % \label{sec:environments} | 3262 | % \label{sec:environments} |
3245 | % \changes{v1.5}{2016/11/14}{Environments may be nested inside the | 3263 | % \changes{v1.5}{2016/11/14}{Environments may be nested inside the |
@@ -3410,9 +3428,9 @@ qAla barzawayhi bn-u 'azhar-a, ra's-u 'a.tibbA'-i fAris-a... | |||
3410 | %</example> | 3428 | %</example> |
3411 | % \fi% | 3429 | % \fi% |
3412 | % This option will prevent \package{babel-french} from interfering | 3430 | % This option will prevent \package{babel-french} from interfering |
3413 | % with the layout of the document. Then the package \package{paralist} | 3431 | % with the layout of the document. Then the \package{paralist} or |
3414 | % can be used to make the lists \enquote*{compact} as | 3432 | % \package{enumitem} packages can be used to make the lists |
3415 | % \package{babel-french} do. | 3433 | % \enquote*{compact} as \package{babel-french} do. |
3416 | % | 3434 | % |
3417 | % \subsection{\package{csquotes}} | 3435 | % \subsection{\package{csquotes}} |
3418 | % \label{sec:csquotes} | 3436 | % \label{sec:csquotes} |
@@ -3453,7 +3471,7 @@ qAla barzawayhi bn-u 'azhar-a, ra's-u 'a.tibbA'-i fAris-a... | |||
3453 | % line in the code above. | 3471 | % line in the code above. |
3454 | % \end{quoting} | 3472 | % \end{quoting} |
3455 | % | 3473 | % |
3456 | % \subsection{Two-argument commands} | 3474 | % \subsection{Two-argument special commands} |
3457 | % \label{sec:two-arg-cmds} | 3475 | % \label{sec:two-arg-cmds} |
3458 | % | 3476 | % |
3459 | % \paragraph{Color} | 3477 | % \paragraph{Color} |
diff --git a/arabluatex.lua b/arabluatex.lua index a395929..94332e0 100644 --- a/arabluatex.lua +++ b/arabluatex.lua | |||
@@ -93,17 +93,6 @@ local bcbracesii = lpeg.Cs(bcbraces^-2) | |||
93 | local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii) | 93 | local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii) |
94 | 94 | ||
95 | local function breakcmd(str) | 95 | local function breakcmd(str) |
96 | for i = 1,#albrkcmds do | ||
97 | str = gsub(str, dblbkslash * lpeg.Cs(albrkcmds[i]) * cmdargs, "}%1%2%3\\arb{") | ||
98 | end | ||
99 | -- user commands | ||
100 | if next(brkcmds) == nil then | ||
101 | -- nothing to do | ||
102 | else | ||
103 | for i = 1,#brkcmds do | ||
104 | str = gsub(str, dblbkslash * lpeg.Cs(brkcmds[i]) * cmdargs, "}%1%2%3\\arb{") | ||
105 | end | ||
106 | end | ||
107 | -- process \item[], then \item[] | 96 | -- process \item[], then \item[] |
108 | str = string.gsub(str, "\\(item.?)(%b[])", | 97 | str = string.gsub(str, "\\(item.?)(%b[])", |
109 | function(tag, body) | 98 | function(tag, body) |
@@ -123,7 +112,19 @@ local function breakcmd(str) | |||
123 | function(tag, body) | 112 | function(tag, body) |
124 | body = string.sub(body, 2, -2) | 113 | body = string.sub(body, 2, -2) |
125 | return string.format("}\\aemph{\\%s{%s}}\\arb{", tag, body) | 114 | return string.format("}\\aemph{\\%s{%s}}\\arb{", tag, body) |
126 | end) | 115 | end) |
116 | -- commands set by default in albrkcmds | ||
117 | for i = 1,#albrkcmds do | ||
118 | str = gsub(str, dblbkslash * lpeg.Cs(albrkcmds[i]) * cmdargs, "}%1%2%3\\arb{") | ||
119 | end | ||
120 | -- user commands | ||
121 | if next(brkcmds) == nil then | ||
122 | -- nothing to do | ||
123 | else | ||
124 | for i = 1,#brkcmds do | ||
125 | str = gsub(str, dblbkslash * lpeg.Cs(brkcmds[i]) * cmdargs, "}%1%2%3\\arb{") | ||
126 | end | ||
127 | end | ||
127 | return str | 128 | return str |
128 | end | 129 | end |
129 | 130 | ||