diff options
Diffstat (limited to 'arabluatex.dtx')
-rw-r--r-- | arabluatex.dtx | 118 |
1 files changed, 109 insertions, 9 deletions
diff --git a/arabluatex.dtx b/arabluatex.dtx index 3dcfc1f..d54290a 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx | |||
@@ -3481,9 +3481,15 @@ muhaddamaTaN mi'_danatu-hu}: \arb[trans]{ra'aytu | |||
3481 | % 'l-\uc{`AdAt-i}}}.\footnote{This is odd in Arabic script, but | 3481 | % 'l-\uc{`AdAt-i}}}.\footnote{This is odd in Arabic script, but |
3482 | % using such features as \cs{emph} or \cs{textbf} is a matter of | 3482 | % using such features as \cs{emph} or \cs{textbf} is a matter of |
3483 | % personal taste.} | 3483 | % personal taste.} |
3484 | % | 3484 | % \NewDocumentCommand{\rlframebox}{o o m}{ |
3485 | % |\arb{\abjad{45} \framebox[1in][s]{kitAbu-hu fI 'l-`AdAti}}|\\ | 3485 | % \IfNoValueTF{#2}{\IfNoValueTF{#1}{ |
3486 | % \arb{\abjad{45} \framebox[1in][s]{kitAbu-hu fI 'l-`AdAti}} | 3486 | % \framebox{\setRL#3}}{\framebox[#1]{\setRL#3}} |
3487 | % }{\framebox[#1][#2]{\setRL#3}}} | ||
3488 | % | ||
3489 | % |\arb{\abjad{45} \rlframebox[1in][s]{kitAbu-hu fI 'l-`AdAti}}|\\ | ||
3490 | % \arb{\abjad{45} \rlframebox[1in][s]{kitAbu-hu fI | ||
3491 | % 'l-`AdAti}}\,\footnote{\cs{rlframefox} has been adapted from | ||
3492 | % \cs{framebox} for insertions of right-to-left text.} | ||
3487 | % \end{quote} | 3493 | % \end{quote} |
3488 | % | 3494 | % |
3489 | % The same applies to footnotes:--- | 3495 | % The same applies to footnotes:--- |
@@ -4051,6 +4057,11 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4051 | \DeclareOptionX{fullvoc}{\def\al@mode{fullvoc}} | 4057 | \DeclareOptionX{fullvoc}{\def\al@mode{fullvoc}} |
4052 | \DeclareOptionX{novoc}{\def\al@mode{novoc}} | 4058 | \DeclareOptionX{novoc}{\def\al@mode{novoc}} |
4053 | \DeclareOptionX{trans}{\def\al@mode{trans}} | 4059 | \DeclareOptionX{trans}{\def\al@mode{trans}} |
4060 | \define@boolkey{arabluatex.sty}[@pkg@]{export}[true]{% | ||
4061 | \AtBeginDocument{\luadirect{al_openstream()}% | ||
4062 | \MkArbBreak{@al@ob, @al@cb}} | ||
4063 | \AtEndDocument{\luadirect{al_closestream()}} | ||
4064 | } | ||
4054 | \ExecuteOptionsX{voc} | 4065 | \ExecuteOptionsX{voc} |
4055 | \ProcessOptionsX\relax | 4066 | \ProcessOptionsX\relax |
4056 | \def\al@mode@voc{voc} | 4067 | \def\al@mode@voc{voc} |
@@ -4315,10 +4326,10 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4315 | % Lua functions to insert transliterated Arabic text. Therefore, it is | 4326 | % Lua functions to insert transliterated Arabic text. Therefore, it is |
4316 | % not documented. | 4327 | % not documented. |
4317 | % \begin{macrocode} | 4328 | % \begin{macrocode} |
4318 | \NewDocumentCommand{\txarb}{+m}{\bgroup\textdir | 4329 | \NewDocumentCommand{\txarb}{+m}{% |
4319 | TRT\arabicfont#1\egroup} | 4330 | \bgroup\textdir TRT\arabicfont#1\egroup} |
4320 | \NewDocumentCommand{\txtrans}{+m}{\bgroup\textdir | 4331 | \NewDocumentCommand{\txtrans}{+m}{% |
4321 | TLT\al@trans@font\al@trans@style#1\egroup} | 4332 | \bgroup\textdir TLT\al@trans@font\al@trans@style#1\egroup} |
4322 | % \end{macrocode} | 4333 | % \end{macrocode} |
4323 | % \end{macro} | 4334 | % \end{macro} |
4324 | % \end{macro} | 4335 | % \end{macro} |
@@ -4451,6 +4462,7 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4451 | \define@key[al]{verse}{color}[]{\color{#1}} | 4462 | \define@key[al]{verse}{color}[]{\color{#1}} |
4452 | \define@boolkey[al]{verse}{utf}[true]{} | 4463 | \define@boolkey[al]{verse}{utf}[true]{} |
4453 | \define@boolkey[al]{verse}{delim}[true]{} | 4464 | \define@boolkey[al]{verse}{delim}[true]{} |
4465 | \define@boolkey[al]{verse}{export}[true]{} | ||
4454 | \define@choicekey[al]{verse}{mode}{fullvoc, voc, novoc, | 4466 | \define@choicekey[al]{verse}{mode}{fullvoc, voc, novoc, |
4455 | trans}{\def\al@mode{#1}} | 4467 | trans}{\def\al@mode{#1}} |
4456 | \presetkeys[al]{verse}{metre={}, utf=false, | 4468 | \presetkeys[al]{verse}{metre={}, utf=false, |
@@ -4459,11 +4471,21 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4459 | % Then follows the environment itself: | 4471 | % Then follows the environment itself: |
4460 | % \begin{macrocode} | 4472 | % \begin{macrocode} |
4461 | \NewDocumentEnvironment{arabverse}{O{}}% | 4473 | \NewDocumentEnvironment{arabverse}{O{}}% |
4462 | {\par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% | 4474 | {\bgroup\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,metre]{#1}% |
4475 | \if@pkg@export\ifal@verse@export% | ||
4476 | \ArbOutFile{\begin{arabverse}}% | ||
4477 | \luadirect{tooutfile(\luastringN{[#1]})}% | ||
4478 | \else\fi\else\fi\egroup% | ||
4479 | \par\centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% | ||
4463 | \ifx\al@mode\al@mode@trans% | 4480 | \ifx\al@mode\al@mode@trans% |
4464 | \ifal@verse@utf\setRL\else\setLR\fi% | 4481 | \ifal@verse@utf\setRL\else\setLR\fi% |
4465 | \else\setRL\fi}% | 4482 | \else\setRL\fi}% |
4466 | {\hfill\setkeys[al]{verse}[width,gutter,utf,mode]{#1}\egroup\par} | 4483 | %{\hfill\setkeys[al]{verse}[width,gutter,utf,mode]{#1}\egroup\par} |
4484 | {\hfill\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,export]{#1}% | ||
4485 | \egroup\par% | ||
4486 | \bgroup\setkeys[al]{verse}[width,gutter,color,utf,delim,mode,metre]{#1}% | ||
4487 | \if@pkg@export\ifal@verse@export% | ||
4488 | \ArbOutFile{\end{arabverse}}\else\fi\else\fi\egroup} | ||
4467 | % \end{macrocode} | 4489 | % \end{macrocode} |
4468 | % \begin{macro}{\bayt} | 4490 | % \begin{macro}{\bayt} |
4469 | % \changes{v1.6}{2016/12/17}{New macro \cs{bayt} for typesetting | 4491 | % \changes{v1.6}{2016/12/17}{New macro \cs{bayt} for typesetting |
@@ -4490,11 +4512,17 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4490 | \NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}} | 4512 | \NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}} |
4491 | \def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt} | 4513 | \def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt} |
4492 | \NewDocumentCommand{\bayt}{m o m}{% | 4514 | \NewDocumentCommand{\bayt}{m o m}{% |
4515 | \if@pkg@export\ifal@verse@export% | ||
4516 | \luadirect{al_doexport("arabverse")}\else\fi\else\fi% | ||
4493 | {^^^^200b}% quick fix to a bug (or a missing feature) in either | 4517 | {^^^^200b}% quick fix to a bug (or a missing feature) in either |
4494 | % luacolor or adjustbox | 4518 | % luacolor or adjustbox |
4495 | \ifdefined\savenotes\savenotes\else\fi% | 4519 | \ifdefined\savenotes\savenotes\else\fi% |
4496 | \edef\al@tatweel{--}% | 4520 | \edef\al@tatweel{--}% |
4521 | \if@pkg@export\ifal@verse@export% | ||
4522 | \ArbOutFile{\bayt\@al@ob}\else\fi\else\fi% | ||
4497 | \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#1}}% | 4523 | \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#1}}% |
4524 | \if@pkg@export\ifal@verse@export% | ||
4525 | \ArbOutFile{\@al@cb}\else\fi\else\fi% | ||
4498 | \IfNoValueTF{#2}{% | 4526 | \IfNoValueTF{#2}{% |
4499 | \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}% | 4527 | \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}% |
4500 | \else% | 4528 | \else% |
@@ -4510,12 +4538,26 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4510 | \fi% | 4538 | \fi% |
4511 | \else% | 4539 | \else% |
4512 | \ifx\al@mode\al@mode@trans% | 4540 | \ifx\al@mode\al@mode@trans% |
4541 | \if@pkg@export\ifal@verse@export% | ||
4542 | \ArbOutFile{[}\else\fi\else\fi% | ||
4513 | \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#2}}% | 4543 | \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#2}}% |
4544 | \if@pkg@export\ifal@verse@export% | ||
4545 | \ArbOutFile{]}\else\fi\else\fi% | ||
4514 | \else% | 4546 | \else% |
4547 | \if@pkg@export\ifal@verse@export% | ||
4548 | \ArbOutFile{[}\else\fi\else\fi% | ||
4515 | \makebox[\al@gutter@width][s]{\arb@utf{#2}}% | 4549 | \makebox[\al@gutter@width][s]{\arb@utf{#2}}% |
4550 | \if@pkg@export\ifal@verse@export% | ||
4551 | \ArbOutFile{]}\else\fi\else\fi% | ||
4516 | \fi\fi}% | 4552 | \fi\fi}% |
4553 | \if@pkg@export\ifal@verse@export% | ||
4554 | \ArbOutFile{\@al@ob}\else\fi\else\fi% | ||
4517 | \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#3}}% | 4555 | \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#3}}% |
4556 | \if@pkg@export\ifal@verse@export% | ||
4557 | \ArbOutFile{\@al@cb\\ }\else\fi\else\fi% | ||
4518 | \ifdefined\spewnotes\spewnotes\else\fi% | 4558 | \ifdefined\spewnotes\spewnotes\else\fi% |
4559 | \if@pkg@export\ifal@verse@export% | ||
4560 | \luadirect{al_doexport("no")}\else\fi\else\fi% | ||
4519 | } | 4561 | } |
4520 | % \end{macrocode} | 4562 | % \end{macrocode} |
4521 | % \end{macro} | 4563 | % \end{macro} |
@@ -4599,6 +4641,64 @@ wa-ya.sIru ta.hta 'l-jild-i | |||
4599 | \AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}} | 4641 | \AtBeginDocument{\deffootnote{2em}{1.6em}{\LR{\thefootnotemark}.\enskip}}}} |
4600 | % \end{macrocode} | 4642 | % \end{macrocode} |
4601 | % \end{macro} | 4643 | % \end{macro} |
4644 | % | ||
4645 | % \paragraph{Exporting Unicode Arabic to external file} | ||
4646 | % \begin{macro}{\SetArbOutSuffix} | ||
4647 | % \changes{v1.13}{2018/08/13}{Sets a suffix to be appended to the | ||
4648 | % filename of the external Unicode file.}By default, |_out| is the | ||
4649 | % suffix to be appended to the external file in which | ||
4650 | % \package{arabluatex} exports Unicode in place of | ||
4651 | % |arabtex| or |buckwalter| strings. Any other suffix may be | ||
4652 | % set with \cs{SetArbOutSuffix}\marg{suffix}. | ||
4653 | % \begin{macrocode} | ||
4654 | \NewDocumentCommand{\SetArbOutSuffix}{m}{ | ||
4655 | \luadirect{al_utffilesuffix(\luastringN{#1})}} | ||
4656 | % \end{macrocode} | ||
4657 | % \end{macro} | ||
4658 | % \begin{macro}{\ArbOutFile} | ||
4659 | % \changes{v1.13}{2018/08/13}{Silently exports its argument in the selected | ||
4660 | % external file.} \cs{ArbOutFile}\oarg{newline}\marg{string} silently | ||
4661 | % exports \meta{string} to the external selected file. It may take | ||
4662 | % |newline| as an optional argument in which case a carriage return is | ||
4663 | % appended to |string|. | ||
4664 | % \begin{macrocode} | ||
4665 | \NewDocumentCommand{\ArbOutFile}{O{no} +m}{% | ||
4666 | \if@pkg@export% | ||
4667 | \luadirect{tooutfile(\luastringN{#2}, "#1")}\else\fi} | ||
4668 | % \end{macrocode} | ||
4669 | % \end{macro} | ||
4670 | % \begin{environment}{arabexport} | ||
4671 | % \changes{v1.13}{2018/08/13}{Processes and print its argument in | ||
4672 | % the current file and exports it in full Unicode in the external | ||
4673 | % selected \texttt{.tex} file.} The |arabexport| environment | ||
4674 | % processes and prints its argument unchanged to the current |.pdf| | ||
4675 | % file. Additionally, if \package{arabluatex} is loaded with the | ||
4676 | % |export| option, this argument is exported to the external | ||
4677 | % selected |.tex| file with Unicode in place of the original | ||
4678 | % |arabtex| or |buckwalter| strings. | ||
4679 | % \begin{macrocode} | ||
4680 | \NewEnviron{arabexport}{% | ||
4681 | \if@pkg@export% | ||
4682 | \par | ||
4683 | \BODY | ||
4684 | \luadirect{al_doexport("yes")} | ||
4685 | \luadirect{tex.sprint(arbtoutf(\luastringO{\BODY}))} | ||
4686 | \else\par\BODY\fi | ||
4687 | }[\if@pkg@export\par\luadirect{al_doexport("no")}\else\par\fi] | ||
4688 | % \end{macrocode} | ||
4689 | % \end{environment} | ||
4690 | % \begin{macro}{\arbpardir} | ||
4691 | % \changes{v1.13}{2018/08/13}{Sets the direction of Arabic paragraphs | ||
4692 | % once they are converted to Unicode.} \cs{arbpardir} is automatically | ||
4693 | % inserted by \package{arabluatex} at the beginning of Arabic | ||
4694 | % paragraphs converted to Unicode so that they are printed in the | ||
4695 | % right direction. | ||
4696 | % \begin{macrocode} | ||
4697 | \NewDocumentCommand{\arbpardir}{}{% | ||
4698 | \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi} | ||
4699 | % \end{macrocode} | ||
4700 | % \end{macro} | ||
4701 | % | ||
4602 | % \subsection*{Errors and Warnings} | 4702 | % \subsection*{Errors and Warnings} |
4603 | % \begin{macrocode} | 4703 | % \begin{macrocode} |
4604 | \newcommand{\al@warning}[1]{\PackageWarning{arabluatex}{#1}} | 4704 | \newcommand{\al@warning}[1]{\PackageWarning{arabluatex}{#1}} |