From ae45238c025af639754aaac12791df232f96ce87 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Sat, 10 Apr 2021 11:24:03 +0200
Subject: added notelang option and updated the documentation

---
 ekdosis.dtx | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 70 insertions(+), 8 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index f7827de..53277e9 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -3190,6 +3190,15 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
 % needed to apply in the apparatus criticus a language different from
 % the one that is selected in the edition text.
 % 
+% \DescribeMacro{\SetApparatusNoteLanguage}
+% \phts\label{ref:app-note-lang}\newfeature[v1.3]
+% \cs{SetApparatusNoteLanguage}\marg{languagename} can be used when it
+% is needed to apply in text entries introduced by the mandatory
+% argument of the \cs{note} command as described in
+% \vref{ref:type-note}\===namely
+% \cs{note}\oarg{options}\marg{text}\===a language different from the
+% one that is selected in the edition text.
+% 
 % \paragraph{General Command}
 % \DescribeMacro{\SetApparatus} \cs{SetApparatus}\marg{csv list of
 % apparatus settings}\phts\label{ref:apparatus-settings-b}\\
@@ -3226,12 +3235,21 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
 % \DescribeOption{lang} |lang|$=$\meta{languagename}
 % \newfeature[v1.2]\phts\label{ref:app-lang-opt}
 % \hfill\tcboxverb{Default: not set}\\
-% \needspace{3\baselineskip}\noindent
 % |lang=<languagename>| is used as described
 % \vpageref[above]{ref:app-lang} when it is needed to apply in the
 % apparatus criticus a language different from the one that is
 % selected in the edition text. |languagename| can be any value
 % accepted by \pkg{babel} or \pkg{polyglossia}.
+% \DescribeOption{notelang} |notelang|$=$\meta{languagename}
+% \newfeature[v1.3]\phts\label{ref:app-note-lang-opt}
+% \hfill\tcboxverb{Default: not set}\\
+% |notelang=<languagename>| is used as described
+% \vpageref[above]{ref:app-note-lang} when is needed to apply in text
+% entries introduced by the mandatory argument of the \cs{note}
+% command as described in \vref{ref:type-note}\===namely
+% \cs{note}\oarg{options}\marg{text}\===a language different from the
+% one that is selected in the edition text. |languagename| can be any
+% value accepted by \pkg{babel} or \pkg{polyglossia}.
 % 
 % As an example, an apparatus criticus with references to line numbers
 % printed in normal font, a colon as a separator between lemma texts
@@ -3327,6 +3345,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
 % \DescribeOption{rule}
 % \DescribeOption{norule}
 % \DescribeOption{lang}\phts\label{ref:apps-lang-opt}
+% \DescribeOption{notelang}
 % With regard to layout, any declared layer inherits the default values
 % described above in \vref{sec:single-layer-app}. That said, as the
 % optional argument of \cs{DeclareApparatus} accepts the exact same
@@ -3524,7 +3543,12 @@ Some \app[type=rec2]{
 % \pkg{ekdosis} to print the line numbers in the apparatus criticus
 % and to set the |left()| XPointer should \texttt{TEI} output be
 % required. Therefore, it must be specified. Otherwise, \pkg{ekdosis}
-% will issue an error message.\\
+% will issue an error message. However, two strictly consecutive
+% \cs{note} commands are allowed to share the same |labelb| value for
+% it may happen that consecutive notes need to refer to spans of text
+% that begin at the exact same location. In this case, \pkg{ekdosis}
+% generates only one \cs{linelabel} and one corresponding
+% |<anchor>| element in the \texttt{TEI xml} file.\\
 % \DescribeOption{labele} |labele|$=$\meta{label}\\
 % |labele| is the unique label to serve as a reference for the point
 % immediately following the lemma text. Contrary to |labelb|, |labele|
@@ -7424,6 +7448,7 @@ Sample text with a \textcolor{red}{word} in red.
   store ehook = \ehook@val,
   store maxentries = \limit@val,
   store lang = \lang@val,
+  store notelang = \notelang@val,
   initial direction = LR,
   initial delim = {},
   initial ehook = {\csname ekd@end@apparatus\endcsname}
@@ -7456,7 +7481,8 @@ Sample text with a \textcolor{red}{word} in red.
     \luastringO{\bhook@val},
     \luastringO{\ehook@val},
     \luastringO{\limit@val},
-    \luastringO{\lang@val}
+    \luastringO{\lang@val},
+    \luastringO{\notelang@val}
     )}
   \egroup
 }
@@ -7594,6 +7620,9 @@ Sample text with a \textcolor{red}{word} in red.
   noval norule = \def\ekd@default@rule{\mbox{}},
   store lang = \ekd@singleapp@lang,
   initial lang = \ltx@ifpackageloaded{babel}{\languagename}{}%
+                 \ltx@ifpackageloaded{polyglossia}{\languagename}{},
+  store notelang = \ekd@singleapp@note@lang,
+  initial notelang = \ltx@ifpackageloaded{babel}{\languagename}{}%
                  \ltx@ifpackageloaded{polyglossia}{\languagename}{}
 }
 %    \end{macrocode}
@@ -7663,6 +7692,18 @@ Sample text with a \textcolor{red}{word} in red.
   \def\ekd@singleapp@lang{#1}}
 %    \end{macrocode}
 % \end{macro}
+% \begin{macro}{\SetApparatusNoteLanguage}
+% \changes{v1.3}{2021/04/02}{defines an alternate language to be
+% applied in note apparatus entries}
+% \cs{SetApparatusNoteLang}\marg{languagename} can be used when
+% it is needed to apply in entries introduced by the \cs{note} command
+% a language different from the one that is selected in the edition
+% text.
+%    \begin{macrocode}
+\NewDocumentCommand{\SetApparatusNoteLanguage}{m}{%
+  \def\ekd@singleapp@note@lang{#1}}
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{\footnoteruletrue}
 % \begin{macro}{\footnoterulefalse}
 % As \pkg{ekdosis} takes care of drawing a rule separating the main
@@ -8126,8 +8167,9 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\app@lang}
-% This macro is used internally by \cs{lem}, \cs{rdg} and \cs{note} to
-% set the language for apparatus entries.
+% \begin{macro}{\app@note@lang}
+% \cs{app@lang} is used internally by \cs{lem} and \cs{rdg} to set the
+% language for apparatus entries. \cs{note} uses \cs{\app@note@lang}.
 %    \begin{macrocode}
 \def\app@lang{%
   \ifekd@mapps
@@ -8136,8 +8178,16 @@ Sample text with a \textcolor{red}{word} in red.
   \ekd@singleapp@lang
   \fi
 }
+\def\app@note@lang{%
+  \ifekd@mapps
+  \luadirect{tex.sprint(ekdosis.getappnotelang(\luastring{\ekdan@type}))}%
+  \else
+  \ekd@singleapp@note@lang
+  \fi
+}
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 % \begin{macro}{\lem}
 % \cs{lem}\oarg{options}\marg{lemma text} inserts \meta{lemma text}
 % both in the edition text and in the apparatus criticus by default,
@@ -8435,7 +8485,7 @@ Sample text with a \textcolor{red}{word} in red.
           \unexpanded\expandafter{\ekdn@sep}\fi
           \else\fi%
           \ifbool{ekd@lang@pkg}%
-          {{\noexpand\selectlanguage{\app@lang}\unexpanded{#2}}}{%
+          {{\noexpand\selectlanguage{\app@note@lang}\unexpanded{#2}}}{%
             {\unexpanded{#2}}}}}%
   \ifekd@mapps%
   \unconditional@appin[\ekdan@type]{\note@contents}%
@@ -10847,7 +10897,8 @@ function ekdosis.newapparatus(teitype,
 			      appbhook,
 			      appehook,
 			      applimit,
-			      applang)
+			      applang,
+			      appnotelang)
    if isintable(apparatuses, teitype)
    then
       tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
@@ -10862,7 +10913,8 @@ function ekdosis.newapparatus(teitype,
 				 bhook = appbhook,
 				 ehook = appehook,
 				 limit = applimit,
-				 lang = applang})
+				 lang = applang,
+				 notelang = appnotelang})
    end
    bagunits[teitype] = 1
    return true
@@ -10878,6 +10930,16 @@ function ekdosis.getapplang(teitype)
    end
 end
 
+function ekdosis.getappnotelang(teitype)
+   i = get_a_index(teitype, apparatuses)
+   if apparatuses[i].notelang ~= ""
+   then
+      return apparatuses[i].notelang
+   else
+      return "\\languagename"
+   end
+end
+
 function ekdosis.getappdelim(str)
    for i = 1,#apparatuses
    do
-- 
cgit v1.2.3

