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 | |
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')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.el | 28 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.pdf | bin | 626929 -> 654353 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.pdf | bin | 111577 -> 111577 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.tex | 3 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/arabluatex/samples/template-01.pdf | bin | 64725 -> 64813 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/lualatex/arabluatex/arabluatex.dtx | 450 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua | 288 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty | 109 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_trans.lua | 12 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua | 8 |
10 files changed, 803 insertions, 95 deletions
diff --git a/Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.el b/Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.el index 810917b4a2d..4fc17b8b197 100644 --- a/Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.el +++ b/Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.el @@ -31,6 +31,7 @@ ("fullvoc") ("novoc") ("trans") + ("export") ) "Global or local options.") @@ -40,13 +41,26 @@ ("width") ("gutter") ("metre") + ("color") ("delim" ("true" "false")) - ("utf" ("true" "false"))) + ("utf" ("true" "false")) + ("export")) "Key=value options for arabverse environment.") (defvar LaTeX-arabluatex-color-options '(())) +(defvar LaTeX-arabluatex-outfile-options + '(;; + (newline)) + "Option for outfile command.") + +(defvar LaTeX-arabluatex-arbmark-options + '(;; + (rl) + (lr)) + "Option for arbmark command.") + (TeX-add-style-hook "arabluatex" (lambda () @@ -62,6 +76,7 @@ "SetTranslitFont" "SetTranslitStyle" "SetTranslitConvention" + "SetArbOutSuffix" "arbup" '("ArbUpDflt" 0) '("NoArbUp" 0) @@ -75,6 +90,15 @@ '("arbcolor" [ (TeX-arg-eval completing-read "Color: " LaTeX-arabluatex-color-options) ] t) + '("arbmark" [ (TeX-arg-eval completing-read "Option: " + LaTeX-arabluatex-arbmark-options) ] + t) + '("ArbOutFile" [ (TeX-arg-eval completing-read "Color: " + LaTeX-arabluatex-outfile-options) ] + t) + '("ArbOutFile*" [ (TeX-arg-eval completing-read "Option: " + LaTeX-arabluatex-outfile-options) ] + t) "SetHemistichDelim" '("bayt" 2) "abjad" @@ -87,7 +111,6 @@ "RLfootnote" "FixArbFtnmk" "MkArbBreak" - "arbmark" '("newarbmark" 3) '("setRL" 0) '("setLR" 0)) @@ -97,6 +120,7 @@ LaTeX-arabluatex-mode-options) ] 0) "txarab" + "arabexport" '("arabverse" LaTeX-env-args [ TeX-arg-key-val LaTeX-arabluatex-key-val-options ] 0)) ) diff --git a/Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.pdf b/Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.pdf Binary files differindex 45e35cdc3ff..d09022ae7d3 100644 --- a/Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.pdf +++ b/Master/texmf-dist/doc/lualatex/arabluatex/arabluatex.pdf diff --git a/Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.pdf b/Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.pdf Binary files differindex 80027660218..f6e94986708 100644 --- a/Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.pdf +++ b/Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.pdf diff --git a/Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.tex b/Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.tex index ff87b2ec9f5..e83b795cbdf 100644 --- a/Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.tex +++ b/Master/texmf-dist/doc/lualatex/arabluatex/samples/al-Jahiz.tex @@ -6,6 +6,9 @@ \documentclass[fontsize=12pt, paper=letter, DIV=classic]{scrartcl} \usepackage{fontspec} \setmainfont{Old Standard} +\usepackage{newunicodechar} +\newunicodechar{ǧ}{ǧ} % Old Standard does include ǧ/Ǧ +\newunicodechar{Ǧ}{Ǧ} % \usepackage{filecontents} \usepackage{xcolor} diff --git a/Master/texmf-dist/doc/lualatex/arabluatex/samples/template-01.pdf b/Master/texmf-dist/doc/lualatex/arabluatex/samples/template-01.pdf Binary files differindex 1a0f8078bfb..79e3f8dab42 100644 --- a/Master/texmf-dist/doc/lualatex/arabluatex/samples/template-01.pdf +++ b/Master/texmf-dist/doc/lualatex/arabluatex/samples/template-01.pdf 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}} diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua index 823823621c1..4db23a295ed 100644 --- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua +++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.lua @@ -49,10 +49,12 @@ local cmdstar = lpeg.Cs(spce * lpeg.P("*")) local bsqbracketsii = lpeg.Cs(bsqbrackets^-2) local bcbracesii = lpeg.Cs(bcbraces^-2) local cmd = lpeg.Cs(dblbkslash * ascii^1 * cmdstar^-1) -local cmdargs = lpeg.Cs(spce * bsqbracketsii * bcbracesii * bsqbrackets^-1) +local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1) +local arbargs = lpeg.Cs(spce^-1 * bsqbrackets^-1 * bcbraces) +local baytargs = lpeg.Cs(spce * bcbraces * bsqbrackets^-1 * bcbraces) local function protectarb(str) - str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\@arb%2%3") + str = string.gsub(str, "(\\arb%s?)(%[.-%])(%b{})", "\\al@brk{\\arb%2%3}") str = string.gsub(str, "(\\LR%s?)(%b{})", "\\@LR%2") str = string.gsub(str, "(\\RL%s?)(%b{})", "\\@RL%2") return str @@ -639,6 +641,210 @@ local function processbuckw(str) return str end +-- The following functions produce a copy of the original .tex source +-- file in which all arabtex strings are replaced with Unicode +-- equivalents +local utffilesuffix = "_out" +local export_utf = "no" + +function al_utffilesuffix(str) + utffilesuffix = str + return true +end + +function al_doexport(str) + export_utf = str + return true +end + +function al_openstream() + local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "a+") + local preamble = io.open(tex.jobname..".tex", "r") + for line in preamble:lines() do + f:write(line, "\n") + if string.find(line, "^%s-\\begin%s?{document}") then + break + end + end + preamble:close() + f:close() + return true +end + +local function processarbtoutf(str) + if export_utf ~= "arabverse" then + str = "\\begin{arabexport}"..str + else end + str = string.gsub(str, "(\\txtrans%s?)(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody) + bbody = string.sub(bbody, 2, -2) + return string.format("%s", bbody) + end) + return string.format("%s{%s}", tag, body) + end) + + str = string.gsub(str, "(\\txarb%s?)(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + body = string.gsub(body, "(\\abjad%s?)(%b{})", function(btag, bbody) + bbody = string.sub(bbody, 2, -2) + if tonumber(bbody) ~= nil then + bbody = abjadify(bbody) + return string.format("\\aemph{\\arb[novoc]{%s}}", bbody) + else + return string.format("%s{%s}", btag, bbody) + end + end) + body = string.gsub(body, "(\\arbmark%s?)(%b{})", function(btag, bbody) + bbody = string.sub(bbody, 2, -2) + return string.format("%s[rl]{%s}", btag, bbody) + end) + return string.format("%s{%s}", tag, body) + end) + str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii) + argi = string.sub(argi, 2, -2) + argii = string.sub(argii, 2, -2) + argiii = string.sub(argiii, 2, -2) + return string.format("%s*{\\arb{%s}}[\\arb{%s}]{\\arb{%s}}", tag, argi, argii, argiii) + end) + str = string.gsub(str, "(\\bayt)%s?(%b{})(%b{})", function(tag, argi, argii) + argi = string.sub(argi, 2, -2) + argii = string.sub(argii, 2, -2) + return string.format("%s*{\\arb{%s}}{\\arb{%s}}", tag, argi, argii) + end) + str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + if string.find(body, "\\uc%s?%b{}") then + return string.format("%s*{%s}", tag, body) + else + return string.format("%s{\\arb[trans]{\\uc{%s}}}", tag, body) + end + end) + str = string.gsub(str, "(\\begin%s?{arab})(%b[])", function(tag, body) + if string.find(body, "trans") then + return string.format("\\par\\bgroup\\setLR\\arb%s{", body) + else + return string.format("\\par\\bgroup\\setRL\\arb%s{", body) + end + end) + str = string.gsub(str, "(\\begin%s?{arab})", "\\par\\bgroup\\arbpardir\\arb{") + str = string.gsub(str, "\\end%s?{arab}", "}\\egroup\\par") + -- This does not work, while the following two do. Look into this later. + -- str = gsub(str, lpeg.Cs("\\arb") * spcenc * bsqbrackets^-1 * bcbraces, function(tag, opt, body) + -- body = string.sub(body, 2, -2) + -- return string.format("%s%s\\@al@pr@ob%s\\@al@pr@cb", tag, opt, body) + -- end) + str = string.gsub(str, "(\\arb%s?)(%b[])(%b{})", function(tag, opt, body) + body = string.sub(body, 2, -2) + return string.format("%s%s\\@al@pr@ob%s\\@al@pr@cb", tag, opt, body) + end) + str = string.gsub(str, "(\\arb)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) + end) + str = string.gsub(str, "(\\arbmark)%s?(%b[])(%b{})", function(tag, opt, body) + body = string.sub(body, 2, -2) + return string.format("%s%s\\@al@pr@ob%s\\@al@pr@cb", tag, opt, body) + end) + str = string.gsub(str, "(\\arbmark)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) + end) + str = string.gsub(str, "(\\[Uu]c)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + return string.format("%s\\@al@pr@ob%s\\@al@pr@cb", tag, body) + end) + str = string.gsub(str, "{", "\\@al@ob") + str = string.gsub(str, "} ", "\\@al@cb@sp") + str = string.gsub(str, "}", "\\@al@cb") + str = string.gsub(str, "\\@al@pr@ob", "{") + str = string.gsub(str, "\\@al@pr@cb", "}") + str = string.gsub(str, "(%b{})", function(body) + body = string.sub(body, 2, -2) + body = string.gsub(body, "(%s?)(\\@al@ob)", "%1{") + body = string.gsub(body, "(\\@al@cb@sp)", "} ") + body = string.gsub(body, "(\\@al@cb)(%s?)", "}%2") + return string.format("{%s}", body) + end) + if export_utf ~= "arabverse" then + str = str.."\\end{arabexport}" + else end + return str +end + +function arbtoutf(str) + str = processarbtoutf(str) + str = "\\ArbOutFile{"..str.."}" + str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + body = gsub(body, lpeg.Cs("\\arb") * arbargs, "}%1%2\\ArbOutFile{") + return string.format("%s{%s}", tag, body) + end) + str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + body = string.gsub(body, "(\\[Uu]c)%s?(%b{})", "}%1%2\\ArbOutFile{") + return string.format("%s{%s}", tag, body) + end) + str = string.gsub(str, "(\\ArbOutFile)%s?(%b{})", function(tag, body) + body = string.sub(body, 2, -2) + body = gsub(body, lpeg.Cs("\\arbmark") * arbargs, "}%1%2\\ArbOutFile{") + return string.format("%s{%s}", tag, body) + end) + return str +end + +function tooutfile(str, nl) + local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "a+") + if nl == "newline" then + f:write(str, "\n\n") + else + f:write(str) + end + f:close() + return str +end + +function al_closestream() + local f = io.open(tex.jobname..utffilesuffix.."_tmp.tex", "r") + local o = io.open(tex.jobname..utffilesuffix..".tex", "w") + local t = f:read("*a") + t = string.gsub(t, "\\arabicfont{}", "") + t = string.gsub(t, "\\par ", "\n\n") + t = string.gsub(t, "(\\@al@ob)", "{") + t = string.gsub(t, "(\\@al@cb@sp)", "} ") + t = string.gsub(t, "(\\@al@cb)(%s?)", "}") + t = gsub(t, lpeg.Cs("\\begin") * spcenc^-1 * bcbraces * cmdargs, "\n%1%2%3\n") + t = string.gsub(t, "(\\\\)(%s?)", "%1\n") + t = string.gsub(t, "(\\\\)(\n)(\\end%s?)(%b{})", "%1%3%4") + t = string.gsub(t, "%s-\n(\\begin%s?)(%b{})", "\n%1%2") + t = string.gsub(t, "(\\item)", "\n%1") + t = string.gsub(t, "\n\n(\\item)", "\n%1") + t = string.gsub(t, "(\\end%s?)(%b{})", "%1%2\n") + t = string.gsub(t, "([^\n]%s-)(\\end)%s?(%b{})", "%1\n%2%3") + t = string.gsub(t, "\n\n\n", "\n\n") + t = string.gsub(t, "(\\txarb%s?%{)(\\txarb%s?)(%b{})(%})", function(tagio, tagii, body, tagic) + body = string.sub(body, 2, -2) + return string.format("%s%s%s", tagio, body, tagic) + end) + t = string.gsub(t, "(\\prname%s?%*%{)(\\txtrans%s?)(%b{})(%})", function(tagio, tagii, body, tagic) + body = string.sub(body, 2, -2) + return string.format("%s%s%s", tagio, body, tagic) + end) + if string.find(t, "\\begin%s?{document}.-\\arb%s?[%[%{]") or + string.find(t, "\\begin%s?{document}.-\\[Uu]c%s?%b{}") + then + tex.print([[\unexpanded{\PackageWarningNoLine{arabluatex}{There are still 'arabtex' strings to be converted. Please open ]]..tex.jobname..utffilesuffix..".tex"..[[ and compile it one more time}}]]) + else end + t = t.."\n\\end{document}" + io.write(t) + o:write(t) + f:close() + o:close() + os.remove(tex.jobname..utffilesuffix.."_tmp.tex") + return true +end + +-- Process standard arabluatex modes: function processvoc(str, rules, scheme) str = takeoutarb(str) str = processarbnull(str, scheme) @@ -655,7 +861,16 @@ function processvoc(str, rules, scheme) str = voc(str, rules) else end str = unprotectarb(str) -return str + if export_utf == "yes" then + tofile = "\\txarb{"..str.."}" + tooutfile(tofile) + elseif export_utf == "arabverse" then + tofile = "\\txarb{"..str.."}" + tooutfile(tofile) + else + return str + end + return "" end function processfullvoc(str, rules, scheme) @@ -676,7 +891,16 @@ function processfullvoc(str, rules, scheme) str = fullvoc(str, rules) else end str = unprotectarb(str) -return str + if export_utf == "yes" then + tofile = "\\txarb{"..str.."}" + tooutfile(tofile) + elseif export_utf == "arabverse" then + tofile = "\\txarb{"..str.."}" + tooutfile(tofile) + else + return str + end + return "" end function processnovoc(str, rules, scheme) @@ -695,7 +919,16 @@ function processnovoc(str, rules, scheme) str = novoc(str) else end str = unprotectarb(str) -return str + if export_utf == "yes" then + tofile = "\\txarb{"..str.."}" + tooutfile(tofile) + elseif export_utf == "arabverse" then + tofile = "\\txarb{"..str.."}" + tooutfile(tofile) + else + return str + end + return "" end function processtrans(str, mode, rules, scheme) @@ -717,7 +950,16 @@ function processtrans(str, mode, rules, scheme) str = transarabica(str) end str = unprotectarb(str) -return str + if export_utf == "yes" then + tofile = str + tooutfile(tofile) + elseif export_utf == "arabverse" then + tofile = str + tooutfile(tofile) + else + return str + end + return "" end function newarbmark(abbr, rtlmk, ltrmk) @@ -736,11 +978,19 @@ local function isintable(table, element) return false end -function processarbmarks(str) +function processarbmarks(str, dir) if not isintable(arbmarks, str) then str = "\\LR{<??>}"..atletter.."\\al@wrong@mark{}"..atother else - if tex.textdir == "TLT" then + if dir == "lr" then + for i = 1,#arbmarks do + str = string.gsub(str, arbmarks[i].a, arbmarks[i].c) + end + elseif dir == "rl" then + for i = 1,#arbmarks do + str = string.gsub(str, arbmarks[i].a, arbmarks[i].b) + end + elseif tex.textdir == "TLT" then for i = 1,#arbmarks do str = string.gsub(str, arbmarks[i].a, arbmarks[i].c) end @@ -750,7 +1000,16 @@ function processarbmarks(str) end end end - return str + if export_utf == "yes" then + tofile = str + tooutfile(tofile) + elseif export_utf == "arabverse" then + tofile = str + tooutfile(tofile) + else + return str + end + return "" end function uc(str) @@ -804,7 +1063,16 @@ function uc(str) for i = 1,#lcuc do str = string.gsub(str, "(%s[%(%<%[]?)"..lcuc[i].a, "%1"..lcuc[i].b) end - return "\\txtrans{"..str.."}" + if export_utf == "yes" then + tofile = "\\txtrans{"..str.."}" + tooutfile(tofile) + elseif export_utf == "arabverse" then + tofile = "\\txtrans{"..str.."}" + tooutfile(tofile) + else + return "\\txtrans{"..str.."}" + end + return "" end -- this function is adapted from an 'obsolete project' of Khaled diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty index 67485aaf4c3..1e90fdfcddb 100644 --- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty +++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex.sty @@ -41,7 +41,7 @@ %% \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} \ifluatex\else \PackageError{arabluatex}{lualatex needed}{% @@ -55,6 +55,11 @@ \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} @@ -71,11 +76,12 @@ \RequirePackage{xparse} \RequirePackage{environ} \RequirePackage{adjustbox} +\RequirePackage{xstring} \newbool{al@rlmode} \luadirect{dofile(kpse.find_file("arabluatex.lua"))} \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}% \AtBeginDocument{\def\setRL{\booltrue{al@rlmode}\pardir TRT\textdir TRT}} \AtBeginDocument{\def\setLR{\boolfalse{al@rlmode}\pardir TLT\textdir TLT}} @@ -127,12 +133,13 @@ \NewDocumentCommand{\uc}{m}% {\luadirect{tex.sprint(uc(\luastringN{#1}))}} \let\Uc\uc -\NewDocumentCommand{\prname}{m}{% - \bgroup\SetTranslitStyle{\relax}\arb[trans]{\uc{#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} +\NewDocumentCommand{\prname}{s m}{% + \bgroup\SetTranslitStyle{\relax}% + \IfBooleanTF{#1}{\txtrans{#2}}{\arb[trans]{\uc{#2}}}\egroup} +\NewDocumentCommand{\txarb}{+m}{% + \bgroup\textdir TRT\arabicfont#1\egroup} +\NewDocumentCommand{\txtrans}{+m}{% + \bgroup\textdir TLT\al@trans@font\al@trans@style#1\egroup} \NewDocumentEnvironment{txarab}{}{% \par% \booltrue{al@rlmode}% @@ -168,10 +175,11 @@ \luastringO{\al@input@scheme}))}\egroup% \else% \fi\fi\fi\fi} -\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} \NewDocumentCommand{\newarbmark}{m m m}{% \luadirect{newarbmark(\luastringN{#1}, \luastringN{#2}, \luastringN{#3})}} @@ -209,34 +217,61 @@ \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, delim=false}{} \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} \NewDocumentCommand{\arb@utf}{m}{% \ifal@verse@utf\txarb{#1}\else\arb{#1}\fi} \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}% @@ -245,11 +280,11 @@ \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% } \AtBeginDocument{% @@ -280,6 +315,36 @@ {\AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}% {\RequirePackage{scrextend} \AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}} +\NewDocumentCommand{\SetArbOutSuffix}{m}{ + \luadirect{al_utffilesuffix(\luastringN{#1})}} +\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} +\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] +\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] +\NewDocumentCommand{\arbpardir}{}{% + \ifx\al@mode\al@mode@trans\setLR\else\booltrue{al@rlmode}\setRL\fi} \newcommand{\al@warning}[1]{\PackageWarning{arabluatex}{#1}} \newcommand{\al@error}[2]{\PackageError{arabluatex}{#1}{#2}} \newcommand{\al@wrong@nesting}{\al@error{% diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_trans.lua b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_trans.lua index 1651418f5ac..775e8207ecf 100644 --- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_trans.lua +++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_trans.lua @@ -43,7 +43,7 @@ captr = { {a="b", b="B"}, {a="t", b="T"}, {a="ṯ", b="Ṯ"}, - {a="ǧ", b="Ǧ"}, + {a="ǧ", b="Ǧ"}, {a="ḥ", b="Ḥ"}, {a="ḫ", b="Ḫ"}, {a="d", b="D"}, @@ -75,7 +75,7 @@ lcuc = { {a="b", b="B"}, {a="t", b="T"}, {a="ṯ", b="Ṯ"}, - {a="ǧ", b="Ǧ"}, + {a="ǧ", b="Ǧ"}, {a="j", b="J"}, {a="ḥ", b="Ḥ"}, {a="ḫ", b="Ḫ"}, @@ -427,7 +427,7 @@ digraphstrdmg = { {a="T(%p*)$", b="h%1"}, {a="T(%p*)(%W)", b="h%1%2"}, {a="_t", b="ṯ"}, - {a="%^g", b="ǧ"}, + {a="%^g", b="ǧ"}, {a="%.h", b="ḥ"}, {a="_h", b="ḫ"}, {a="_d", b="ḏ"}, @@ -462,7 +462,7 @@ digraphstrdmg = { singletrdmg = { {a="b", b="b"}, {a="t", b="t"}, - {a="j", b="ǧ"}, + {a="j", b="ǧ"}, {a="x", b="ḫ"}, {a="d", b="d"}, {a="r", b="r"}, @@ -949,7 +949,7 @@ digraphstrarabica = { {a="aT(%p*)$", b="a%1"}, {a="aT(%p*%s)", b="a%1"}, {a="_t", b="ṯ"}, - {a="%^g", b="ǧ"}, + {a="%^g", b="ǧ"}, {a="%.h", b="ḥ"}, {a="_h", b="ḫ"}, {a="_d", b="ḏ"}, @@ -983,7 +983,7 @@ digraphstrarabica = { singletrarabica = { {a="b", b="b"}, {a="t", b="t"}, - {a="j", b="ǧ"}, + {a="j", b="ǧ"}, {a="x", b="ḫ"}, {a="d", b="d"}, {a="r", b="r"}, diff --git a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua index 3f4cce960ff..842f42b78ee 100644 --- a/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua +++ b/Master/texmf-dist/tex/lualatex/arabluatex/arabluatex_voc.lua @@ -23,10 +23,10 @@ along with this program. If not, see --]] arbmarks = { - {a="bismillah", b="\\arabicfont ^^^^fdfd", c="\\arb[trans]{bi-ismi \\uc{'l-l_ahi} 'l-ra.hm_ani 'l-ra.hImi}"}, - {a="salam", b="\\arabicfont ^^^^fdf5", c="\\arb[trans]{.sall_A\\arbnull{'l-l_ahu} \\uc{'l-l_ahu} `alay-hi wa-sallama}"}, - {a="jalla", b="\\arabicfont ^^^^fdfb", c="\\arb[trans]{^galla ^galAla-hu}"}, - {a="slm", b="\\arabicfont ^^^^fdfa", c="\\arb[trans]{.sall_A\\arbnull{'l-l_ahu} \\uc{'l-l_ahu} `alay-hi wa-sallama}"} + {a="bismillah", b="\\arabicfont{}^^^^fdfd", c="\\arb[trans]{bi-ismi \\uc{'l-l_ahi} 'l-ra.hm_ani 'l-ra.hImi}"}, + {a="salam", b="\\arabicfont{}^^^^fdf5", c="\\arb[trans]{.sall_A\\arbnull{'l-l_ahu} \\uc{'l-l_ahu} `alay-hi wa-sallama}"}, + {a="jalla", b="\\arabicfont{}^^^^fdfb", c="\\arb[trans]{^galla ^galAla-hu}"}, + {a="slm", b="\\arabicfont{}^^^^fdfa", c="\\arb[trans]{.sall_A\\arbnull{'l-l_ahu} \\uc{'l-l_ahu} `alay-hi wa-sallama}"} } abjad = { |