From 4bbe70f21cec5cdf6331bd2bcfd654c031389243 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sun, 21 May 2023 11:35:45 +0200 Subject: let critical notes be inserted in lines of poetry with ekdosis --- arabluatex.dtx | 189 ++++++++++++++++++++++++++++++++++++++------------------- arabluatex.el | 1 + arabluatex.lua | 8 +-- 3 files changed, 131 insertions(+), 67 deletions(-) diff --git a/arabluatex.dtx b/arabluatex.dtx index c585c9e..4d6a00d 100644 --- a/arabluatex.dtx +++ b/arabluatex.dtx @@ -26,7 +26,7 @@ %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{arabluatex} %<*package> - [2023/01/24 v1.21-dev ArabTeX for LuaLaTeX] + [2023/05/21 v1.21-dev ArabTeX for LuaLaTeX] % % %<*driver> @@ -77,6 +77,15 @@ url = {http://www.amirifont.org/} } +@software{pkg:ekdosis, + title = {The Ekdosis package}, + subtitle = {Typesetting TEI-xml compliant Critical Editions}, + author = {Alessi, Robert}, + url = {http://www.ekdosis.org}, + date = {2021-11-21}, + version = {1.4} +} + @Book{Habash, author = {Habash, Nizar Y.}, title = {Introduction to Arabic Natural Language Processing}, @@ -175,7 +184,7 @@ \usepackage{lettrine} \newcommand\danger{\lettrine[loversize=-.5]{\textdbend}{\hskip6pt}} \usepackage{metalogox} -\usepackage{arabluatex}[2023/01/24] +\usepackage{arabluatex}[2023/05/21] \SetTranslitConvention{dmg+} \SetArbUp{\textsuperscript{\thinspace#1}} % Old Standard needs this \usepackage[nopar]{quran} @@ -267,8 +276,6 @@ label*=\textsc{Rem.} \emph{\alph*}, left=0.25in, before=\smaller} -\usepackage{multicol} -\setlength\IndexMin{100pt} \usepackage{quoting} \quotingsetup{noorphans, rightmargin=0pt} \renewcommand*{\quotingfont}{\footnotesize} @@ -297,7 +304,7 @@ \DeclareQuoteStyle{arabic} {\rmfamily\textquotedblright}{\rmfamily\textquotedblleft} {\rmfamily\textquoteright}{\rmfamily\textquoteleft} -\usepackage[style=authoryear, indexing=cite]{biblatex} +\usepackage[style=oxnotes-inote,indexing=cite]{biblatex} \DeclareIndexFieldFormat{indextitle}{\index{#1=\emph{#1}}} \addbibresource{arabluatex.bib} \NewDocumentCommand{\newfeature}{o}{% @@ -316,24 +323,27 @@ \renewcommand\cftlottitlefont{\Large\bfseries} \usepackage{etoc} \etocsettocdepth{paragraph} +\makeatletter \newcommand{\altableofcontents}{% \begingroup \etocsetstyle{section}{}{} - {\etocsavedsectiontocline{% + {\l@section{% \numberline{\etocnumber}\etocname}{\etocpage}}{} \etocsetstyle{subsection}{}{} - {\etocsavedsubsectiontocline{% + {\l@subsection{% \numberline{\etocnumber}\etocname}{\etocpage}}{}% \etocsetstyle{subsubsection}{}{} - {\etocsavedsubsubsectiontocline{% + {\l@subsubsection{% \numberline{\etocnumber}\etocname}{\etocpage}}{}% \etocsetstyle{paragraph}{}{\leftskip2cm\rightskip 2.2em \parfillskip 0pt plus 1fil\relax \nobreak} {\noindent\etocname{} \etocpage{} }{\par}% \etocmulticolstyle[2]{\section*{Contents}} \pdfbookmark[1]{Contents}{toc} - \tableofcontents + \etoctoclines + \localtableofcontents \endgroup} +\makeatother \setlength\IndexMin{100pt} \EnableCrossrefs \RecordChanges @@ -427,11 +437,11 @@ % input notation. Its output can be set in the same modes of % vocalization as Arab\TeX, or in different roman % transliterations. It further allows many typographical -% refinements. It will eventually interact with some other packages -% yet to come to produce from \verb|.tex| source files, in addition -% to printed books, \texttt{TEI xml} compliant critical editions -% and/or lexicons that can be searched, analyzed and correlated in -% various ways. +% refinements. Furthermore, it can interact with the \pkg{ekdosis} +% package to produce from \verb|.tex| source files, in addition to +% printed books, \texttt{TEI xml} compliant critical editions and/or +% lexicons that can be searched, analyzed and correlated in various +% ways. % \end{abstract} % % \section*{License and Disclaimer} @@ -2380,8 +2390,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. % 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:---% +% should be used.} Additionally, every \cs{bayt} command \emph{must} +% be followed with |\\| like so:--- +% % \iffalse %<*example> % \fi @@ -2516,6 +2527,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. % package can also be used for the same effect. However, it must be % loaded \emph{after} \package{arabluatex}.} % +% \needspace{3\baselineskip} +% \paragraph{Critical Notes} +% \DescribeMacro{\bayt+} \newfeature[v1.21] If the \pkg{ekdosis} +% package be loaded,\footcite{pkg:ekdosis} the \cs{bayt} command also +% accepts a |+| optional argument that can be used to let critical +% notes be inserted in lines of poetry. Details on how to use this +% command are provided in the relevant section of the documentation of +% the \pkg{ekdosis} package.\footcite[\nopp see \enquote{Arabic +% Poetry}]{pkg:ekdosis} +% % \paragraph{Line numbering} % Inside the |arabverse| environment, the |linenumbers| environment of % the \package{lineno} package can be used to have the lines of @@ -4631,7 +4652,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. % \end{macrocode} % \end{macro} % \begin{macro}{\SetArbNumbers} -% \changes{v1.21}{2023/01/24}{selects Indian or Arabic numbers} +% \changes{v1.21}{2023/05/21}{selects Indian or Arabic numbers} % \begin{macrocode} \NewDocumentCommand{\SetArbNumbers}{m}{% \luadirect{arabluatex.setnums(\luastringN{#1})}% @@ -4794,7 +4815,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. % \end{macrocode} % \end{macro} % \begin{macro}{\altrfont} -% \changes{v1.21}{2023/01/24}{new command \cs{altrfont} to store +% \changes{v1.21}{2023/05/21}{new command \cs{altrfont} to store % font and shape information (trans mode)} Finally \cs{altrfont} % is used internally by \package{arabluatex} to store family and % shape information about the font to be used for transliterated @@ -5031,55 +5052,63 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. % \begin{macrocode} \newlength{\al@bayt@width} \newlength{\al@gutter@width} +\newlength{\al@verse@twidth} \setlength{\al@bayt@width}{.3\textwidth} \setlength{\al@gutter@width}{.15\al@bayt@width} \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}{metre}{\def\al@verse@metre@value{\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}{} +\presetkeys[al]{verse}{utf=false, delim=false}{} % \end{macrocode} % Then follows the environment itself: % \begin{macrocode} \NewDocumentEnvironment{arabverse}{!O{}}% {\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{arabluatex.tooutfile(\luastringN{[#1]})}% - % \else% - \IfSubStr[1]{#1}{utf}% + \if@pkg@export + \ifal@verse@export + \ArbOutFile{\begin{arabverse}}% + % \ifx\al@mode\al@mode@trans% + % \luadirect{arabluatex.tooutfile(\luastringN{[#1]})}% + % \else% + \IfSubStr[1]{#1}{utf}% {\luadirect{arabluatex.tooutfile(\luastringN{[#1]})}}% {\luadirect{arabluatex.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% - \ifal@verse@utf% - \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi% - \else% - \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi% - \fi% - \arab@v@export[#1] + % \fi + \else + \fi + \else + \fi + \egroup + \centering\noindent\bgroup\setkeys[al]{verse}[metre]{#1}% + % \ifx\al@mode\al@mode@trans% + % \ifal@verse@utf\setRL\else\setLR\fi% + % \else\setRL\fi% + \ifal@verse@utf + \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi + \else + \ifx\al@mode\al@mode@trans\setLR\else\setRL\fi + \fi + \addtolength{\al@verse@twidth}{2\al@bayt@width}% + \addtolength{\al@verse@twidth}{\al@gutter@width}% + \arab@v@export[#1] }% {\endarab@v@export - \hfill\setkeys[al]{verse}[width, gutter, color, utf, delim, mode, + \setkeys[al]{verse}[width, gutter, color, utf, delim, mode, export]{#1}% - \egroup\par% + \ifdefined\al@verse@metre@value\hfill\al@verse@metre@value\fi + \egroup \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} + \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 @@ -5128,22 +5157,33 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \def\al@hemistich@delim{*} \NewDocumentCommand{\SetHemistichDelim}{m}{\def\al@hemistich@delim{#1}} \def\al@verse@stroke{\leavevmode\xleaders\hbox{\arb{--}}\hfill\kern0pt} -\NewDocumentCommand{\bayt}{s m o m}{% - \IfBooleanTF{#1}{\relax}{\relax}% +\providebool{ekd@state} +\NewDocumentCommand{\bayt}{t+ s m o m}{% + \IfBooleanTF{#1}{% + \ifekd@state + \leavevmode + \stepcounter{ekd@lab}% + \zlabel{ekd:\theekd@lab}% + \luadirect{ekdosis.storeabspg( + \luastring{\zref@extract{ekd:\theekd@lab}{abspage}})}% + \add@apparatus + \fi + }{\relax}% + \IfBooleanTF{#2}{\relax}{\relax}% \ifdefined\savenotes\savenotes\else\fi% \edef\al@tatweel{--}% \ifal@warp@bayt% - \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#2}}% + \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#3}}% \else% - \makebox[\al@bayt@width][s]{\arb@utf{#2}}% + \makebox[\al@bayt@width][s]{\arb@utf{#3}}% \fi% - \IfNoValueTF{#3}{% + \IfNoValueTF{#4}{% \ifal@verse@delim\makebox[\al@gutter@width][c]{\al@hemistich@delim}% \else% \hspace{\al@gutter@width}% \fi }{% - \edef\@tempa{#3}% + \edef\@tempa{#4}% \ifx\@tempa\al@tatweel% \ifx\al@mode\al@mode@trans% \hspace{\al@gutter@width}% @@ -5153,17 +5193,17 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \else% \ifx\al@mode\al@mode@trans% \ifal@warp@bayt% - \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#3}}% + \adjustbox{width=\al@gutter@width, height=\Height}{\arb@utf{#4}}% \else% - \makebox[\al@gutter@width][s]{\arb@utf{#3}}% + \makebox[\al@gutter@width][s]{\arb@utf{#4}}% \fi% \else% - \makebox[\al@gutter@width][s]{\arb@utf{#3}}% + \makebox[\al@gutter@width][s]{\arb@utf{#4}}% \fi\fi}% \ifal@warp@bayt% - \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#4}}% + \adjustbox{width=\al@bayt@width, height=\Height}{\arb@utf{#5}}% \else% - \makebox[\al@bayt@width][s]{\arb@utf{#4}}% + \makebox[\al@bayt@width][s]{\arb@utf{#5}}% \fi% \ifdefined\spewnotes\spewnotes\else\fi% } @@ -5400,14 +5440,37 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \NewDocumentEnvironment{arab@v@export}{O{} +b}{% \setkeys[al]{verse}[width, gutter, color, utf, delim, mode, metre]{#1} - \if@pkg@export\ifal@verse@export% - \par - #2 - \luadirect{arabluatex.doexport("arabverse")} - \luadirect{tex.sprint(arabluatex.arbtoutf(\luastringN{#2}))} - \luadirect{arabluatex.doexport("no")} - \else\par#2\fi\else\par#2\fi -}{\par} + \if@pkg@export + \ifal@verse@export + \ifekd@state + \begin{ekdverse}[width=\al@verse@twidth] + #2 + \end{ekdverse} + \else + #2 + \fi + \luadirect{arabluatex.doexport("arabverse")}% + \luadirect{tex.sprint(arabluatex.arbtoutf(\luastringN{#2}))}% + \luadirect{arabluatex.doexport("no")}% + \else + \ifekd@state + \begin{ekdverse}[width=\al@verse@twidth] + #2 + \end{ekdverse} + \else + #2 + \fi + \fi + \else + \ifekd@state + \begin{ekdverse}[width=\al@verse@twidth] + #2 + \end{ekdverse} + \else + #2 + \fi + \fi +}{} % \end{macrocode} % \end{environment} % \begin{macro}{\arbpardir} diff --git a/arabluatex.el b/arabluatex.el index e445aca..5007675 100644 --- a/arabluatex.el +++ b/arabluatex.el @@ -125,6 +125,7 @@ TeX-arg-index) "SetHemistichDelim" '("bayt" 2) + '("bayt+" 2) "abjad" '("SetArbNumbers" "Indian or Arabic") "arbnull" diff --git a/arabluatex.lua b/arabluatex.lua index bce9e0f..ec318b7 100644 --- a/arabluatex.lua +++ b/arabluatex.lua @@ -821,16 +821,16 @@ local function processarbtoutf(str) end) return string.format("%s{%s}", tag, body) end) - str = string.gsub(str, "(\\bayt)%s?(%b{})(%b[])(%b{})", function(tag, argi, argii, argiii) + str = string.gsub(str, "(\\bayt)%s?(%+?)(%b{})(%b[])(%b{})", function(tag, plus, 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) + return string.format("%s%s*{\\arb{%s}}[\\arb{%s}]{\\arb{%s}}", tag, argi, argii, argiii) end) - str = string.gsub(str, "(\\bayt)%s?(%b{})(%b{})", function(tag, argi, argii) + str = string.gsub(str, "(\\bayt)%s?(%+?)(%b{})(%b{})", function(tag, plus, 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) + return string.format("%s%s*{\\arb{%s}}{\\arb{%s}}", tag, plus, argi, argii) end) str = string.gsub(str, "(\\prname)%s?(%b{})", function(tag, body) body = string.sub(body, 2, -2) -- cgit v1.2.3