From 9ed235c0bea637355cfa53222ae263cabc476ba8 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Fri, 1 Jun 2018 10:35:11 +0200 Subject: breakcmd(): iteration through albrkcmds and brkcmds had to be moved down. still documenting --- arabluatex.dtx | 34 ++++++++++++++++++++++++++-------- 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... % % \DescribeMacro{\MkArbBreak} The \cs{MkArbBreak}\marg{csv list of % commands} command can be used in the preamble to give any -% \emph{single-argument} command---either new or already -% existing---the precedence over \package{arabluatex} inside Arabic -% environments. It takes as argument a comma-separated list of -% commands each of which must be stripped of its leading character +% command---either new or already existing---the precedence over +% \package{arabluatex} inside Arabic environments. It takes as +% argument a comma-separated list of commands each of which must be +% stripped of its leading character % |\|, like so:---\\ % \arabluaverb{\MkArbBreak{onecmd, anothercmd, yetanothercmd, ...}} % @@ -3240,6 +3240,24 @@ qAla barzawayhi bn-u 'azhar-a, ra's-u 'a.tibbA'-i fAris-a... % % \fi % +% It must be noted that the arguments, either optional or mandatory, +% of commands declared with \cs{MkArbBreak} are not to be processed by +% \package{arabluatex}. Therefore, as in the previous example, any of +% their argument to be rendered in Arabic must be inserted again in +% \cs{arb}. \NEWfeature{v1.12}These commands themselves may have up to +% two optional and/or mandatory arguments, like so:--- +% \begin{compactenum}[(a)] +% \item \cs{command} (no argument, lowermost combination) +% \item \cs{command}\oarg{opt1} (one optional argument) +% \item \cs{command}\marg{arg1} (one mandatory argument) +% \item \cs{command}\oarg{opt1}\marg{arg1} (one optional and one +% mandatory argument) +% \item (\ldots) +% \item \cs{command}\oarg{opt1}\oarg{opt2}\marg{arg1}\marg{arg2} +% (uppermost combination) +% \end{compactenum} +% +% % \subsection{Environments} % \label{sec:environments} % \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... % % \fi% % This option will prevent \package{babel-french} from interfering -% with the layout of the document. Then the package \package{paralist} -% can be used to make the lists \enquote*{compact} as -% \package{babel-french} do. +% with the layout of the document. Then the \package{paralist} or +% \package{enumitem} packages can be used to make the lists +% \enquote*{compact} as \package{babel-french} do. % % \subsection{\package{csquotes}} % \label{sec:csquotes} @@ -3453,7 +3471,7 @@ qAla barzawayhi bn-u 'azhar-a, ra's-u 'a.tibbA'-i fAris-a... % line in the code above. % \end{quoting} % -% \subsection{Two-argument commands} +% \subsection{Two-argument special commands} % \label{sec:two-arg-cmds} % % \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) local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii) local function breakcmd(str) - for i = 1,#albrkcmds do - str = gsub(str, dblbkslash * lpeg.Cs(albrkcmds[i]) * cmdargs, "}%1%2%3\\arb{") - end - -- user commands - if next(brkcmds) == nil then - -- nothing to do - else - for i = 1,#brkcmds do - str = gsub(str, dblbkslash * lpeg.Cs(brkcmds[i]) * cmdargs, "}%1%2%3\\arb{") - end - end -- process \item[], then \item[] str = string.gsub(str, "\\(item.?)(%b[])", function(tag, body) @@ -123,7 +112,19 @@ local function breakcmd(str) function(tag, body) body = string.sub(body, 2, -2) return string.format("}\\aemph{\\%s{%s}}\\arb{", tag, body) - end) + end) + -- commands set by default in albrkcmds + for i = 1,#albrkcmds do + str = gsub(str, dblbkslash * lpeg.Cs(albrkcmds[i]) * cmdargs, "}%1%2%3\\arb{") + end + -- user commands + if next(brkcmds) == nil then + -- nothing to do + else + for i = 1,#brkcmds do + str = gsub(str, dblbkslash * lpeg.Cs(brkcmds[i]) * cmdargs, "}%1%2%3\\arb{") + end + end return str end -- cgit v1.2.3