From db5c8d1fcfcd1b4398719c6de1e6cd78ab62c5f8 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sat, 24 Jun 2017 21:16:22 +0200 Subject: new command \arbcolor which does the same as \textcolor in Arabic environments --- arabluatex.dtx | 53 +++++++++++++++++++++++++++++++++++------------------ arabluatex.lua | 6 +++--- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/arabluatex.dtx b/arabluatex.dtx index 4da2745..b323ada 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx @@ -227,7 +227,7 @@ % % \fi % -% \CheckSum{700} +% \CheckSum{0} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -2282,6 +2282,24 @@ word that \cs{arbnull} is applied to. % % \fi % +% \paragraph{Color} +% Here comes the example: +% For example, to distinguish words with a different color, one may +% proceed like so:--- +% \iffalse +%<*example> +% \fi +\begin{arabluacode} +\begin{arab} +_tumma "intalaqa _dU 'l-qarn-ayni 'il_A 'ummaT-iN 'u_hr_A fI +\arbcolor{red}{\arb[fullvoc]{((ma.tli`-i 'l-^sams-i))}} +wa-lA binA'-a la-hum yu'amminu-hum mina 'l-^sams-i. +\end{arab} +\end{arabluacode} +% \iffalse +% +% \fi +% % \section{Transliteration} % \label{sec:transliteration} % It may be more appropriate to speak of \enquote{romanization} than @@ -2794,23 +2812,7 @@ al-muqAtil-Ina.}, wa-kAnat 'ummI min `u.zamA'-i buyUt-i % \DescribeMacro{\RL} \cs{RL}\marg{arg} does the same as % \cs{LR}\marg{arg}, but typesets its argument from right to left. Even % in an Arabic environment, this command may be useful. -% -% For example, to distinguish words with a different color, one may -% proceed like so:--- -% \iffalse -%<*example> -% \fi -\begin{arabluacode} -\begin{arab} -_tumma "intalaqa _dU 'l-qarn-ayni 'il_A 'ummaT-iN 'u_hr_A fI -\LR{\textcolor{red}{\arb[fullvoc]{((ma.tli`-i 'l-^sams-i))}}} -wa-lA binA'-a la-hum yu'amminu-hum mina 'l-^sams-i. -\end{arab} -\end{arabluacode} -% \iffalse -% -% \fi -% +% % \DescribeMacro{\LRfootnote} \DescribeMacro{\RLfootnote} % \cs{LRfootnote}\marg{text} and \cs{RLfootnote}\marg{text} typeset % left-to-right and right-to-left footnotes respectively in Arabic @@ -3461,6 +3463,21 @@ wa-ya.sIru ta.hta 'l-jild-i \else \fi\fi\fi\fi}[\par] % \end{macrocode} % \end{environment} +% \begin{macro}{\arbcolor} +% \changes{v1.8.6}{2017/06/25}{New \cs{arbcolor} command} +% \cs{arbcolor} is the equivalent for the \cs{textcolor} command. Just +% as the latter, it takes two mandatory arguments. Of course, +% \cs{textcolor} must be defined for \cs{arbcolor} to work. +% takes two mandatory arguments. +% \begin{macrocode} +\NewDocumentCommand{\arbcolor}{m m}{% + \ifdefined\textcolor% + \textcolor{#1}{#2}% + \else\@gobble#1% + \arb{#2} + \fi} +% \end{macrocode} +% \end{macro} % \begin{environment}{arabverse} % \changes{v1.6}{2016/12/17}{New environment \texttt{arabverse} for % typesetting Arabic poetry} The |arabverse| environment may receive diff --git a/arabluatex.lua b/arabluatex.lua index ffdc7c7..c8011b1 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -73,12 +73,12 @@ local function breakcmd(str) body = string.sub(body, 2, -2) return string.format("}\\%s{%s}\\arb{", tag, body) end) - -- \textcolor - str = string.gsub(str, "\\(textcolor.-)(%b{})(%b{})", + -- \arbcolor + str = string.gsub(str, "\\(arbcolor.-)(%b{})(%b{})", function(tag, bodycolor, bodytext) bodycolor = string.sub(bodycolor, 2, -2) bodytext = string.sub(bodytext, 2, -2) - return string.format("}\\%s{%s}{\\arb{%s}}\\arb{", tag, bodycolor, bodytext) + return string.format("}\\textcolor{%s}{\\arb{%s}}\\arb{", bodycolor, bodytext) end) -- Footnote str = string.gsub(str, "\\(Footnote.-)(%b{})", -- cgit v1.2.3