diff options
author | Karl Berry <karl@freefriends.org> | 2018-08-27 21:40:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-08-27 21:40:31 +0000 |
commit | f1c2e4e8b45c0e7bbdaca6e345c187375d024f6a (patch) | |
tree | 860c73f354a94aaca03662a2cddce04ff0063f46 /Master/texmf-dist/source/lualatex | |
parent | c357ace7563241fac62d6f2a73fc3a1521e628b2 (diff) |
arabluatex (27aug18)
git-svn-id: svn://tug.org/texlive/trunk@48499 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/lualatex')
-rw-r--r-- | Master/texmf-dist/source/lualatex/arabluatex/arabluatex.dtx | 450 |
1 files changed, 399 insertions, 51 deletions
diff --git a/Master/texmf-dist/source/lualatex/arabluatex/arabluatex.dtx b/Master/texmf-dist/source/lualatex/arabluatex/arabluatex.dtx index 2f6c92a7cdf..44d443c1f4f 100644 --- a/Master/texmf-dist/source/lualatex/arabluatex/arabluatex.dtx +++ b/Master/texmf-dist/source/lualatex/arabluatex/arabluatex.dtx @@ -27,7 +27,7 @@ %<package-info>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package-info>\ProvidesPackage{arabluatex} %<*package-info> - [2018/06/24 v1.12 An ArabTeX-like interface for LuaLaTeX] + [2018/08/27 v1.13 An ArabTeX-like interface for LuaLaTeX] %</package-info> % %<*driver> @@ -155,7 +155,10 @@ \defaultfontfeatures{RawFeature={+liga}} \setmainfont{Old Standard}[SmallCapsFont={Latin Modern Roman Caps}, RawFeature={+mark;+ccmp;+ss05;+ss06}] -\usepackage{arabluatex}[2018/06/24] +\usepackage{newunicodechar} +\newunicodechar{ǧ}{ǧ} % Old Standard does not include ǧ/Ǧ +\newunicodechar{Ǧ}{Ǧ} % +\usepackage{arabluatex}[2018/08/27] \usepackage[nopar]{quran} \usepackage[noindex]{nameauth} \usepackage{varioref} @@ -188,6 +191,7 @@ \setlist[enumabjad]{label={\abjad{\arabic*}}} \usepackage{multicol} \usepackage{cleveref} +\crefname{footnote}{note}{notes} \usepackage{quoting} \quotingsetup{noorphans, rightmargin=0pt} \renewcommand*{\quotingfont}{\footnotesize} @@ -212,7 +216,6 @@ \DeclareTotalTCBox{\arabluabox}{m}{left=0mm, right=0mm, top=0mm, bottom=0mm, colback=white, boxrule=.15mm, colframe=red!50!white}{#1} -\usepackage{xcolor} \newcommand{\package}[1]{\textsf{#1}\index{#1=#1 (package)}} \usepackage{csquotes} \DeclareQuoteStyle{arabic} @@ -257,7 +260,7 @@ %</driver> % \fi % -% \CheckSum{784} +% \CheckSum{896} % % \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 @@ -525,7 +528,7 @@ % \textsc{Rem.} By default Amiri places the \arb[trans]{kasraT} in % combination with the \arb[trans]{ta^sdId} below the consonant, % like so: \arb{BBi}\,. That is correct, as at least in the oldest -% manuscripts {\newfontfamily\arabicfont{Amiri}[Script=Arabic, +% manuscripts {\renewfontfamily\arabicfont{Amiri}[Script=Arabic, % RawFeature={+ss05}]\arb{BBi}} may stand for \arb{BBa} as % well as \arb{BBi}\,. See \textcite[i. 14 C--D]{Wright}. The placement % of the \arb[trans]{kasraT} above the consonant may be obtained by @@ -539,11 +542,11 @@ % % \subsection{Options} % \label{sec:options} -% \package{arabluatex} may be loaded with four mutually exclusive -% global options, each of which may be overriden at any point of the -% document (see below \vref{sec:local-options}): +% \package{arabluatex} may be loaded with five global options, the +% first four of which are mutually exclusive and may be overriden at +% any point of the document (see below \vref{sec:local-options}): % -% \DescribeOption{voc}\hfill\arabluaverb{default}\\ In this mode, +% \DescribeOption{voc}\hfill\arabluaverb{Default}\\ In this mode, % which is the one selected by default, every short vowel written % generates its corresponding diacritical mark: \arb[trans]{.dammaT} % (\arb{Bu}), \arb[trans]{fat.haT} (\arb{Ba}) and \arb[trans]{kasraT} @@ -576,6 +579,16 @@ % \end{description} % More standards will be included in future releases of % \package{arabluatex}. +% +% \label{ref:export-global-opt} +% \DescribeOption{export} |export|$=$|true|\verb+|+|false| +% \hfill\arabluaverb{Default: false}\\ \label{export-mode} +% \NEWfeature{v.1.13} This option acts as a named argument and does +% not need a value as it defaults to |true| if it is used. It enables +% \package{arabluatex} to produce a duplicate of the original |.tex| +% source file in which all \textsc{ascii} strings are replaced with +% Unicode equivalents. See below \vref{sec:arabtex2utf} for more +% information. % % \subsubsection{Classic contrasted with modern typesetting of Arabic} % \label{sec:classic-modern-typesetting} @@ -829,6 +842,7 @@ vowels (see §~3). % \vref{ref:hamza}.} & \dmg{'u 'a 'i} & % \loc{|'u, |'a, |'i} & \brill{|'u, |'a, |'i} & |'u| or |'a| or |'i| \\ % \arb[novoc]{b} & \dmg{b} & \loc{b} & \brill{b} & |b| \\ +% \pagebreak[1] % \arb[novoc]{t} & \dmg{t} & \loc{t} & \brill{t} & |t| \\ % \arb[novoc]{_t} & \dmg{_t} & \loc{_t} & \brill{_t} & |_t| \\ % \arb[novoc]{j} & \dmg{j} & \loc{j} & \brill{j} & |^g| or |j| \\ @@ -2106,7 +2120,7 @@ word that \cs{arbnull} is applied to. % \arb[novoc]{.k} & \dmg{.k} & \loc{.k} & \brill{.k} & |.k| \\ % \arb[novoc]{.n} & \dmg{.n} & \loc{.n} & \brill{.n} & |.n| \\ % \arb[novoc]{((} & \dmg{((} & \loc{((} & \brill{((} & |((| \\ -% \pagebreak +% \pagebreak[1] % \arb[novoc]{))} & \dmg{))} & \loc{))} & \brill{))} & |))| \\ % \end{longtable} % @@ -2208,10 +2222,30 @@ word that \cs{arbnull} is applied to. % environment instead of \textsc{ascii} Arab\TeX\ or Buckwalter input % schemes. See \vref{sec:unicode-input} for more details. % +% \DescribeOption{color} |color|$=$\meta{color name} +% \hfill\arabluaverb{Default: not set}\\ +% \NEWfeature{v1.13} The color in which lines of poetry are to be +% rendered. +% +% \label{ref:poetry-export} +% \DescribeOption{export} |export|$=$|true|\verb+|+|false| +% \hfill\arabluaverb{Default: false}\\ +% \NEWfeature{v.1.13} This named argument does not need a value as it +% defaults to |true| if it is used. If |export| is set as a global +% option as well (see above \vpageref{export-mode}), all the lines +% will be converted to Unicode and exported to the external selected +% file. See below \vref{sec:arabtex2utf} for more details. +% % \DescribeMacro{\bayt} Inside the |arabverse| environment, each line % is typeset by the \cs{bayt} command which takes two mandatory -% arguments and may accept one optional argument. Additionally, every -% \cs{bayt} command \emph{must} be followed with |\\| like so:---% +% arguments and may accept one optional +% argument.\footnote{\label{ref:bayt-star}A \enquote*{starred} version +% \cs{bayt*} is also defined. \package{arabluatex} uses it internally +% when \texttt{export} is set to \texttt{true} to instruct some Lua +% functions that lines of poetry have already been processed. That +% aside, \cs{bayt} and \cs{bayt*} do the same, and only \cs{bayt} +% should be used.} Additionally, every \cs{bayt} command \emph{must} +% be followed with |\\| like so:---% % \iffalse %<*example> % \fi @@ -2486,10 +2520,10 @@ word that \cs{arbnull} is applied to. % \arb[trans]{\uc{qur'An}} or in classical poetry. % % \DescribeMacro{\arbmark} -% \NEWfeature{v1.11}\cs{arbmark}\marg{shorthand} can be used to insert -% such characters either in Unicode or in romanized Arabic -% environments. It takes as argument a shorthand defined beforehand in -% a default list which consists of the following +% \NEWfeature{v1.11}\cs{arbmark}\oarg{rl\textbar{}lr}\marg{shorthand} +% can be used to insert such characters either in Unicode or in +% romanized Arabic environments. It takes as argument a shorthand +% defined beforehand in a default list which consists of the following % at the time of writing:---\\ % \begin{longtable}{llp{.3\linewidth}p{.3\linewidth}} % \bottomrule @@ -2509,6 +2543,11 @@ word that \cs{arbnull} is applied to. % |FDFA| & |slm| & \arb{\arbmark{slm}} & \arbmark{slm} \\ % |FDFB| & |jalla| & \arb{\arbmark{jalla}} & \arbmark{jalla} \\ % \end{longtable} +% +% \NEWfeature{v1.13} +% The mark to be inserted is determined by contextual analysis, or by +% an optional argument, either |rl| to have the Arabic glyph printed, +% or |lr| to print the tranliterated equivalent. % % \DescribeMacro{\newarbmark} \NEWfeature{v1.11} \cs{newarbmark} is % also provided should one wish to define new marks in addition to the @@ -2659,7 +2698,8 @@ word that \cs{arbnull} is applied to. % % \Cref{tab:arbcolor-diacritics} gives the Arab\TeX\ equivalents for % the diacritics to be printed inside or just after \cs{arbcolor}. -% +% +% \needspace{7\baselineskip} % \begin{longtable}{lllll} % \bottomrule % \caption*{\Cref*{tab:arbcolor-diacritics}: Arab\TeX\ diacritics @@ -3085,7 +3125,16 @@ Then as \Hunayn, \Razi. % \iffalse %</example> % \fi -% +% +% \begin{quoting}\label{ref:prname-star} +% \textsc{Rem.} \DescribeMacro{\prname*} \package{arabluatex} also +% provides \cs{prname*} which only renders in upright roman style +% already transliterated proper names without applying any further +% processing. It is mostly used internally and applied to proper +% names exported in Unicode to an external selected +% file.\footnote{See below \vref{sec:arabtex2utf} for more details.} +% \end{quoting} +% % \subsection{Additional note on \texttt{dmg} convention} % \label{sec:additional-note-dmg} % \NEWfeature{v1.3} According to \textcite[6]{dmg}, Arabic @@ -3349,13 +3398,14 @@ muhaddamaTaN mi'_danatu-hu}: \arb[trans]{ra'aytu % \arb[novoc]{_d} & \dmg{_d} & \loc{_d} & \brill{_d} & |*| & |V| \\ % \arb[novoc]{r} & \dmg{r} & \loc{r} & \brill{r} & |r| & |r| \\ % \arb[novoc]{z} & \dmg{z} & \loc{z} & \brill{z} & |z| & |z| \\ +% \pagebreak[1] % \arb[novoc]{s} & \dmg{s} & \loc{s} & \brill{s} & |s| & |s| \\ % \arb[novoc]{^s} & \dmg{^s} & \loc{^s} & \brill{^s} & |$| & |c| \\ % \arb[novoc]{.s} & \dmg{.s} & \loc{.s} & \brill{.s} & |S| & |S| \\ -% \pagebreak[1] % \arb[novoc]{.d} & \dmg{.d} & \loc{.d} & \brill{.d} & |D| & |D| \\ % \arb[novoc]{.t} & \dmg{.t} & \loc{.t} & \brill{.t} & |T| & |T| \\ % \arb[novoc]{.z} & \dmg{.z} & \loc{.z} & \brill{.z} & |Z| & |Z| \\ +% \pagebreak[1] % \arb[novoc]{`} & \dmg{`} & \loc{`} & \brill{`} & |E| & |E| \\ % \arb[novoc]{.g} & \dmg{.g} & \loc{.g} & \brill{.g} & |g| & |g| \\ % \arb[novoc]{f} & \dmg{f} & \loc{f} & \brill{f} & |f| & |f| \\ @@ -3476,9 +3526,15 @@ muhaddamaTaN mi'_danatu-hu}: \arb[trans]{ra'aytu % 'l-\uc{`AdAt-i}}}.\footnote{This is odd in Arabic script, but % using such features as \cs{emph} or \cs{textbf} is a matter of % personal taste.} -% -% |\arb{\abjad{45} \framebox[1in][s]{kitAbu-hu fI 'l-`AdAti}}|\\ -% \arb{\abjad{45} \framebox[1in][s]{kitAbu-hu fI 'l-`AdAti}} +% \NewDocumentCommand{\rlframebox}{o o m}{ +% \IfNoValueTF{#2}{\IfNoValueTF{#1}{ +% \framebox{\setRL#3}}{\framebox[#1]{\setRL#3}} +% }{\framebox[#1][#2]{\setRL#3}}} +% +% |\arb{\abjad{45} \rlframebox[1in][s]{kitAbu-hu fI 'l-`AdAti}}|\\ +% \arb{\abjad{45} \rlframebox[1in][s]{kitAbu-hu fI +% 'l-`AdAti}}\,\footnote{\cs{rlframefox} has been adapted from +% \cs{framebox} for insertions of right-to-left text.} % \end{quote} % % The same applies to footnotes:--- @@ -3563,6 +3619,7 @@ al-muqAtil-Ina.}, wa-kAnat 'ummI min `u.zamA'-i buyUt-i % other single-argument command inserted in Arabic environments. The % general principle laid \vpageref{ref:cmd-inside-arabic} applies. % +% \label{ref:setrl-setlr} % \DescribeMacro{\setRL} \DescribeMacro{\setLR} \cs{setRL} and % \cs{setLR} can be used to change the direction of paragraphs, either % form left to right or from right to left. As an example, an @@ -3986,7 +4043,164 @@ wa-ya.sIru ta.hta 'l-jild-i % \iffalse %</example> % \fi +% +% \section{Exporting Unicode Arabic to an external file} +% \label{sec:arabtex2utf} +% \NEWfeature{v.1.13}\package{arabluatex} is able to produce a +% duplicate of the original |.tex| source file in which all |arabtex| +% or |buckwalter| strings will have been replaced with Unicode +% equivalents, either in Arabic script or in any accepted standard of +% transliteration. Exporting \textsc{ascii} strings to Unicode while +% preserving the exact selected global or local options is a fairly +% complex operation which may require \hologo{LuaLaTeX} to be run +% several times as will be explained below. +% +% \subsection{Commands and environments} +% \paragraph{\texttt{export} global option} +% \DescribeOption{export} First, \package{arabluatex} must be loaded +% with the |export| global option enabled,\footnote{See above +% \vpageref{ref:export-global-opt} for more information.} like +% so:--- % +% \iffalse +%<*example> +% \fi +\begin{arabluaverbatim} + % preamble + \usepackage[export]{arabluatex} + % or: + \usepackage[export=true]{arabluatex} +\end{arabluaverbatim} +% \iffalse +%</example> +% \fi +% +% Once that is done, compiling the current file will produce a new +% empty external |.tex| file with the same preamble as the original +% file. +% +% \DescribeMacro{\SetArbOutSuffix} By default, |_out| is appended as a +% suffix to the external file name. Any other suffix may be set with +% the command \cs{SetArbOutSuffix}\marg{suffix}. +% +% \paragraph{Exporting running paragraphs} +% \DescribeEnv{arabexport} Then, the |arabexport| environment is +% provided to actually exporting running paragraphs with or without +% Arabic environments to the external selected file, like so:--- % +% \iffalse +%<*example> +% \fi +\begin{arabluaverbatim} + \begin{arabexport} + <Running paragraphs of either Arabic or non-Arabic text> + \end{arabexport} +\end{arabluaverbatim} +% \iffalse +%</example> +% \fi +% +% \package{arabluatex} converts to Unicode and writes to the external +% file what is found inside Arabic environments. As to non-Arabic +% text, it is appended untouched to this file, which is formatted as +% follows:--- +% \begin{enumerate} +% \item Unicode Arabic text, either in Arabic script or in +% transliteration, is inserted as argument of +% \cs{txarb}\footnote{See above \vref{sec:unicode-input}.} or +% \cs{txtrans}\footnote{\cs{txtrans} is used internally by several +% Lua functions to format transliterated Arabic. Therefore, it is +% not documented.} accordingly. +% \item \DescribeMacro{\arbpardir}Additionally, Arabic paragraphs may +% receive \cs{arbpardir}, which \package{arabluatex} uses to +% determine the direction of Arabic paragraphs to be set by default, +% or either \cs{setRL} or \cs{setLR} depending on what may have been +% set locally.\footnote{See above \vpageref{ref:setrl-setlr}.} +% \item \DescribeMacro{\prname*}Proper names are inserted as arguments +% of \cs{prname*}.\footnote{See above \vpageref{ref:prname-star}.} +% \end{enumerate} % +% \paragraph{Appending words or commands to the external file only} +% \DescribeMacro{\ArbOutFile}\DescribeMacro{\ArbOutFile*} +% \cs{ArbOutFile}\oarg{newline}\allowbreak\marg{argument} silently +% exports its argument to the external file. It may take the string +% |newline| as an optional argument, in which case a carriage return +% is appended to the contents of the +% argument. \cs{ArbOutFile*}\oarg{newline}\marg{argument} does the +% same as \cs{ArbOutFile}, but also inserts its argument into the +% current |.tex| source file. +% +% \paragraph{Exporting Arabic poetry} +% Lines of Arabic poetry are exported as described above +% \vpageref{ref:poetry-export} when the |export| option that is +% specific to the |arabverse| environment is set to |true|. As a +% result of this particular feature, |arabverse| environments must be +% left outside |\begin{arabexport}| \ldots\ |\end{arabexport}|. +% +% Please note that inside |arabverse| environments \cs{bayt} is +% replaced with \cs{bayt*}.\footnote{See above \vref{ref:bayt-star} for +% more information.} +% +% \subsection{Nested Arabic environments} +% The exporting mechanism described above converts only the outermost +% level of nested Arabic environments. This may be sufficient in some +% cases, but if nested Arabic environments be found in the original +% |.tex| source file, then the Unicode converted file must be opened +% and compiled in turn, and so on until the innermost Arabic +% environment be converted and exported. In such cases, +% \package{arabluatex} issues a warning, so that authors do not have +% to check the entire file that just has been exported:--- % +% \iffalse +%<*example> +% \fi +\begin{arabluaverbatim} + Package arabluatex Warning: There are still 'arabtex' strings + to be converted. Please open <jobname><suffix>.tex and compile + it one more time. +\end{arabluaverbatim} +% \iffalse +%</example> +% \fi +% Where \meta{jobname} is the name of the original |.tex| source file, +% and \meta{suffix} the suffix appended to the file that is to be +% opened and compiled again. +% +% \subsection{Further processing of Unicode converted files} +% \label{sec:further-processing-utf-files} +% Unicode files can be further processed by document converters such +% as John McFarlane's |pandoc|\footnote{See +% \url{http://pandoc.org/}}. To take here one simple example, here is +% how |file_out.tex| can be converted from \hologo{LuaLaTeX} into Open +% Document format (|.odt|):---% +% \iffalse +%<*example> +% \fi +\begin{arabluaverbatim} + pandoc file_out.tex -s -o file_out.odt +\end{arabluaverbatim} +% \iffalse +%</example> +% \fi +% +% However, specific commands such as \cs{txarb}, \cs{txtrans} or +% \cs{prname*}, which are not known to |pandoc|, must be redefined +% explicitly in the preamble to prevent the converter from gobbling +% their arguments, like so:---% +% \iffalse +%<*example> +% \fi +\begin{arabluaverbatim} + % preamble: + \usepackage{arabluatex} % note that 'export' has been removed + \renewcommand{\txarb}[1]{#1} + \renewcommand{\txtrans}[1]{\emph{#1}} + % now that \prname{} has been replaced with \prname*{} it should + % be safe to say: + \renewcommand{\prname}[2]{#2} + % &c +\end{arabluaverbatim} +% \iffalse +%</example> +% \fi +% % \section{Future work} % \label{sec:future-work} % A short, uncommented, list of what is planned in the versions of @@ -4025,7 +4239,7 @@ wa-ya.sIru ta.hta 'l-jild-i % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{arabluatex}% -[2018/06/24 v1.12 An ArabTeX-like interface for LuaLaTeX] +[2018/08/27 v1.13 An ArabTeX-like interface for LuaLaTeX] \RequirePackage{ifluatex} % \end{macrocode} % \package{arabluatex} requires \hologo{LuaLaTeX} of course. Issue a @@ -4046,6 +4260,11 @@ wa-ya.sIru ta.hta 'l-jild-i \DeclareOptionX{fullvoc}{\def\al@mode{fullvoc}} \DeclareOptionX{novoc}{\def\al@mode{novoc}} \DeclareOptionX{trans}{\def\al@mode{trans}} +\define@boolkey{arabluatex.sty}[@pkg@]{export}[true]{% + \AtBeginDocument{\luadirect{al_openstream()}% + \MkArbBreak{@al@ob,@al@cb,@al@cb@sp}} + \AtEndDocument{\luadirect{al_closestream()}} +} \ExecuteOptionsX{voc} \ProcessOptionsX\relax \def\al@mode@voc{voc} @@ -4065,6 +4284,7 @@ wa-ya.sIru ta.hta 'l-jild-i \RequirePackage{xparse} \RequirePackage{environ} \RequirePackage{adjustbox} +\RequirePackage{xstring} % \end{macrocode} % The following boolean will be set to |true| in |RL| mode: % \begin{macrocode} @@ -4078,8 +4298,8 @@ wa-ya.sIru ta.hta 'l-jild-i % and attempt to load the Amiri font which is included in \TeX{}live: % \begin{macrocode} \AtBeginDocument{\ifdefined\arabicfont\relax\else -\PackageWarning{arabluatex}{\string\arabicfont\ is not defined.^^JI - will try to load Amiri}% +\PackageWarning{arabluatex}{\string\arabicfont\ is not defined.^^J + I will try to load Amiri}% \newfontfamily\arabicfont[Script=Arabic]{Amiri}\fi}% % \end{macrocode} % \begin{macro}{\setRL} @@ -4297,11 +4517,18 @@ wa-ya.sIru ta.hta 'l-jild-i % to be used outside Arabic environments for proper names. It takes as % argument one or more Arabic words, each of which will be rendered in % upright roman style with its first letter uppercased. +% \begin{macro}{\prname*}\changes{v1.13}{2018/08/27}{Renders proper +% names already converted to Unicode in upright roman style} +% Unlike \cs{prname}, \cs{prname*} does not take |arabtex| or +% |buckwalter| input as argument, but already Unicode converted +% names and renders them in upright roman style. % \begin{macrocode} -\NewDocumentCommand{\prname}{m}{% - \bgroup\SetTranslitStyle{\relax}\arb[trans]{\uc{#1}}\egroup} +\NewDocumentCommand{\prname}{s m}{% + \bgroup\SetTranslitStyle{\relax}% + \IfBooleanTF{#1}{\txtrans{#2}}{\arb[trans]{\uc{#2}}}\egroup} % \end{macrocode} % \end{macro} +% \end{macro} % \begin{macro}{\txarb} \cs{txarb} sets the direction to right-to-left % and selects the Arabic font. It is used internally by several Lua % functions, but available to the user should he wish to insert @@ -4310,10 +4537,10 @@ wa-ya.sIru ta.hta 'l-jild-i % Lua functions to insert transliterated Arabic text. Therefore, it is % not documented. % \begin{macrocode} -\NewDocumentCommand{\txarb}{+m}{\bgroup\textdir - TRT\arabicfont#1\egroup} -\NewDocumentCommand{\txtrans}{+m}{\bgroup\textdir - TLT\al@trans@font\al@trans@style#1\egroup} +\NewDocumentCommand{\txarb}{+m}{% + \bgroup\textdir TRT\arabicfont#1\egroup} +\NewDocumentCommand{\txtrans}{+m}{% + \bgroup\textdir TLT\al@trans@font\al@trans@style#1\egroup} % \end{macrocode} % \end{macro} % \end{macro} @@ -4368,14 +4595,20 @@ wa-ya.sIru ta.hta 'l-jild-i % \end{macrocode} % \end{macro} % \begin{macro}{\arbmark} -% \changes{v1.11}{2018/03/31}{New command for inserting additional -% marks in Arabic environments} \cs{arbmark} takes one argument from a -% list of defined elements. This command is coded in Lua. +% \changes{v1.11}{2018/03/31}{New command for inserting additional +% marks in Arabic environments} +% \cs{arbmark}\oarg{rl\textbar{}lr}\marg{shorthand} takes one +% argument from a list of defined elements. +% \changes{v1.13}{2018/08/27}{New optional argument: either +% \texttt{rl} or \texttt{lr}} The mark to be inserted is determined +% by contextual analysis or by an optional argument, either |rl| or +% |lr|. This command is coded in Lua. % \begin{macrocode} -\NewDocumentCommand{\arbmark}{m}{% +\NewDocumentCommand{\arbmark}{O{} m}{% \bgroup% \SetInputScheme{arabtex}% - \luadirect{tex.sprint(processarbmarks(\luastringN{#1}))}% + \luadirect{tex.sprint(processarbmarks(\luastringN{#2}, + \luastringN{#1}))}% \egroup} % \end{macrocode} % \end{macro} @@ -4427,9 +4660,12 @@ wa-ya.sIru ta.hta 'l-jild-i % \begin{environment}{arabverse} % \changes{v1.6}{2016/12/17}{New environment \texttt{arabverse} for % typesetting Arabic poetry} The |arabverse| environment may receive -% different options: |mode|, |width|, |gutter|, |metre|, |utf| -% and |delim|; all of them are defined here just before the -% |arabverse| environment: +% different options: |mode|, |width|, |gutter|, |metre|, |color|, +% |utf|, |delim| and |export|; all of them are defined here just +% before the |arabverse| +% environment. \changes{v1.13}{2018/08/27}{New options +% \texttt{color} and \texttt{export} to \texttt{arabverse} +% environment.} % \begin{macrocode} \newlength{\al@bayt@width} \newlength{\al@gutter@width} @@ -4438,8 +4674,10 @@ wa-ya.sIru ta.hta 'l-jild-i \define@key[al]{verse}{width}{\setlength{\al@bayt@width}{#1}} \define@key[al]{verse}{gutter}{\setlength{\al@gutter@width}{#1}} \define@key[al]{verse}{metre}{\arb{#1}} +\define@key[al]{verse}{color}[]{\color{#1}} \define@boolkey[al]{verse}{utf}[true]{} \define@boolkey[al]{verse}{delim}[true]{} +\define@boolkey[al]{verse}{export}[true]{} \define@choicekey[al]{verse}{mode}{fullvoc, voc, novoc, trans}{\def\al@mode{#1}} \presetkeys[al]{verse}{metre={}, utf=false, @@ -4448,11 +4686,33 @@ wa-ya.sIru ta.hta 'l-jild-i % Then follows the environment itself: % \begin{macrocode} \NewDocumentEnvironment{arabverse}{O{}}% -{\par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% +{\bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, + metre]{#1}% + \if@pkg@export\ifal@verse@export% + \ArbOutFile{\begin{arabverse}}% + \ifx\al@mode\al@mode@trans% + \luadirect{tooutfile(\luastringN{[#1]})}% + \else% + \IfSubStr[1]{#1}{utf}% + {\luadirect{tooutfile(\luastringN{[#1]})}}% + {\luadirect{tooutfile(\luastringN{[#1, utf]})}}% + \fi + \else\fi\else\fi\egroup% + \par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% \ifx\al@mode\al@mode@trans% - \ifal@verse@utf\setRL\else\setLR\fi% - \else\setRL\fi}% -{\hfill\setkeys[al]{verse}[width,gutter,utf,mode]{#1}\egroup} + \ifal@verse@utf\setRL\else\setLR\fi% + \else\setRL\fi% + \arab@v@export{#1} + }% + {\endarab@v@export + \hfill\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, + export]{#1}% + \egroup\par% + \bgroup\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, + metre]{#1}% + \if@pkg@export\ifal@verse@export% + \ArbOutFile{\end{arabverse}} + \else\fi\else\fi\egroup} % \end{macrocode} % \begin{macro}{\bayt} % \changes{v1.6}{2016/12/17}{New macro \cs{bayt} for typesetting @@ -4478,17 +4738,20 @@ wa-ya.sIru ta.hta 'l-jild-i \def\al@hemistich@delim{*} \NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}} \def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt} -\NewDocumentCommand{\bayt}{m o m}{% +\NewDocumentCommand{\bayt}{s m o m}{% + \IfBooleanTF{#1}{\relax}{\relax}% + {^^^^200b}% quick fix to a bug (or a missing feature) in either + % luacolor or adjustbox \ifdefined\savenotes\savenotes\else\fi% \edef\al@tatweel{--}% - \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#1}}% - \IfNoValueTF{#2}{% + \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#2}}% + \IfNoValueTF{#3}{% \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}% \else% \hspace{\al@gutter@width}% \fi }{% - \edef\@tempa{#2}% + \edef\@tempa{#3}% \ifx\@tempa\al@tatweel% \ifx\al@mode\al@mode@trans% \hspace{\al@gutter@width}% @@ -4497,15 +4760,15 @@ wa-ya.sIru ta.hta 'l-jild-i \fi% \else% \ifx\al@mode\al@mode@trans% - \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#2}}% + \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#3}}% \else% - \makebox[\al@gutter@width][s]{\arb@utf{#2}}% + \makebox[\al@gutter@width][s]{\arb@utf{#3}}% \fi\fi}% - \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#3}}% + \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#4}}% \ifdefined\spewnotes\spewnotes\else\fi% } % \end{macrocode} -% \end{macro} +% \end{macro} % \end{environment} % \begin{macro}{\abjad} \cs{abjad}\marg{number} expresses its argument % in Arabic letters in accordance with the \arb[trans]{'abjad} @@ -4586,6 +4849,91 @@ wa-ya.sIru ta.hta 'l-jild-i \AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}} % \end{macrocode} % \end{macro} +% +% \paragraph*{Exporting Unicode Arabic to external file} +% \begin{macro}{\SetArbOutSuffix} +% \changes{v1.13}{2018/08/27}{Sets a suffix to be appended to the +% filename of the external Unicode file.}By default, |_out| is the +% suffix to be appended to the external file in which +% \package{arabluatex} exports Unicode in place of +% |arabtex| or |buckwalter| strings. Any other suffix may be +% set with \cs{SetArbOutSuffix}\marg{suffix}. +% \begin{macrocode} +\NewDocumentCommand{\SetArbOutSuffix}{m}{ + \luadirect{al_utffilesuffix(\luastringN{#1})}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ArbOutFile} +% \changes{v1.13}{2018/08/27}{Silently exports its argument in the +% selected external file.} +% \cs{ArbOutFile}\oarg{newline}\marg{string} silently exports +% \meta{string} to the external selected file. It may take |newline| +% as an optional argument in which case a carriage return is +% appended to |string|. +% \begin{macro}{\ArbOutFile*} +% \cs{ArbOutFile*}\oarg{newline}\marg{string} does the same as +% \cs{ArbOutFile} but also inserts \meta{string} in the current +% |.tex| source file. +% \begin{macrocode} +\NewDocumentCommand{\ArbOutFile}{s O{no} +m}{% + \if@pkg@export% + \IfBooleanTF{#1}{% + #3\luadirect{tooutfile(\luastringN{#3}, "#2")}}{% + \luadirect{tooutfile(\luastringN{#3}, "#2")}}% + \else\IfBooleanTF{#1}{#3}{}\fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{environment}{arabexport} +% \changes{v1.13}{2018/08/27}{Processes and print its argument in +% the current file and exports it in full Unicode in the external +% selected \texttt{.tex} file.} The |arabexport| environment +% processes and prints its argument unchanged to the current |.pdf| +% file. Additionally, if \package{arabluatex} is loaded with the +% |export| option, this argument is exported to the external +% selected |.tex| file with Unicode in place of the original +% |arabtex| or |buckwalter| strings. +% \begin{macrocode} +\NewEnviron{arabexport}{% + \if@pkg@export% + \par + \BODY + \luadirect{al_doexport("yes")} + \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))} + \luadirect{al_doexport("no")} + \else\par\BODY\fi + }[\par] +% \end{macrocode} +% \end{environment} +% \begin{environment}{arab@v@export} The |arab@v@export| environment +% does for |arabverse| the same as |arabexport|. It is used +% internally by |arabverse|. +% \begin{macrocode} +\NewEnviron{arab@v@export}[1]{% + \setkeys[al]{verse}[width, gutter, color, utf, delim, mode, + metre]{#1} + \if@pkg@export\ifal@verse@export% + \par + \BODY + \luadirect{al_doexport("arabverse")} + \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))} + \luadirect{al_doexport("no")} + \else\par\BODY\fi\else\par\BODY\fi +}[\par] +% \end{macrocode} +% \end{environment} +% \begin{macro}{\arbpardir} +% \changes{v1.13}{2018/08/27}{Sets the direction of Arabic paragraphs +% once they are converted to Unicode.} \cs{arbpardir} is automatically +% inserted by \package{arabluatex} at the beginning of Arabic +% paragraphs converted to Unicode so that they are printed in the +% right direction. +% \begin{macrocode} +\NewDocumentCommand{\arbpardir}{}{% + \ifx\al@mode\al@mode@trans\setLR\else\booltrue{al@rlmode}\setRL\fi} +% \end{macrocode} +% \end{macro} +% % \subsection*{Errors and Warnings} % \begin{macrocode} \newcommand{\al@warning}[1]{\PackageWarning{arabluatex}{#1}} |