From 4216653b8eec8568b2ee6b5d50fba88a25637346 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Sat, 25 May 2024 10:42:13 +0200
Subject: fixed order of appearance of wit-source-resp in RL mode (and also
 prewit-wit-postwit in both modes)

---
 ekdosis.dtx | 172 ++++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 114 insertions(+), 58 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index d558e13..0f6917b 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1,7 +1,7 @@
 % \iffalse meta-comment
 % 
 % ekdosis -- Typesetting TEI xml-compliant critical editions
-% Copyright (c) 2020, 2021, 2022, 2023  Robert Alessi
+% Copyright (c) 2020, 2021, 2022, 2023, 2024  Robert Alessi
 % <alessi@robertalessi.net>
 % 
 % Permission to use, copy, modify, and distribute this software for any
@@ -27,7 +27,7 @@
 This file is part of the `ekdosis' package
 
 ekdosis -- Typesetting TEI xml-compliant critical editions
-Copyright (c) 2020, 2021, 2022, 2023  Robert Alessi
+Copyright (c) 2020, 2021, 2022, 2023, 2024  Robert Alessi
 <alessi@robertalessi.net>
 
 Permission to use, copy, modify, and distribute this software for any
@@ -59,7 +59,7 @@ Alessi <alessi@robertalessi.net>
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{ekdosis}
 %<*package>
-    [2023/07/29 v1.5-dev Typesetting TEI xml-compliant critical editions]
+    [2024/05/25 v1.5-dev Typesetting TEI xml-compliant critical editions]
 %</package>
 %<*driver>
 \begin{filecontents}[noheader,overwrite]{bibdata.xml}
@@ -860,7 +860,7 @@ Alessi <alessi@robertalessi.net>
   Para ver una copia de esta licencia, siga el vínculo:
   \metapick[#1]{licenseurl}.}
 \metaset{copyrightowner}{\metapick[#1]{author}}
-\metaset{copyrightdate}{2020, 2021, 2022, 2023}
+\metaset{copyrightdate}{2020, 2021, 2022, 2023, 2024}
 \metaset{licensemessage}{Permission to use, copy, modify, and
   distribute this software for any purpose with or without fee is
   hereby granted, provided that the above copyright notice and this
@@ -1063,7 +1063,7 @@ Alessi <alessi@robertalessi.net>
 ekdosis -- Typesetting TEI xml-Compliant Critical Editions
 ----------------------------------------------------------
 
-Copyright (c) 2020, 2021, 2022, 2023 Robert Alessi
+Copyright (c) 2020, 2021, 2022, 2023, 2024 Robert Alessi
 <alessi@robertalessi.net>
 
 Permission to use, copy, modify, and distribute this software for any
@@ -8519,7 +8519,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \paragraph{\textsf{ekdosis} Symbol}
 % \begin{macro}{\eKd}
-% \changes{v1.5}{2023/07/29}{Prints \textsf{ekdosis} indentifying
+% \changes{v1.5}{2024/05/25}{Prints \textsf{ekdosis} indentifying
 % symbol} As of v1.5, \pkg{ekdosis} has its own identifying
 % symbol. It is produced by \cs{eKd} and best printed with the Old
 % Standard Greek font.
@@ -8782,7 +8782,7 @@ Sample text with a \textcolor{red}{word} in red.
 % \begin{macro}{\teidirectE}
 % \changes{v1.3}{2021/08/18}{direct insertion of elements in the
 % \texttt{TEI xml} file}
-% \changes{v1.5}{2023/07/29}{direct insertion of empty elements in the
+% \changes{v1.5}{2024/05/25}{direct insertion of empty elements in the
 % \texttt{TEI xml} file}
 % \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code}
 % does nothing in \LaTeX. It is only used to insert elements in the
@@ -8797,7 +8797,7 @@ Sample text with a \textcolor{red}{word} in red.
 % \end{macro}
 % \end{macro}
 % \begin{macro}{\getTEIxmlid}
-% \changes{v1.5}{2023/07/29}{returns \texttt{TEI xml:ids} from a
+% \changes{v1.5}{2024/05/25}{returns \texttt{TEI xml:ids} from a
 % csv-list of ids} This command returns from a csv-list of unique
 % identifiers declared in commands such as \cs{DeclareWitness} and the
 % like a space-separated list of their corresponding |xml:id|s, each
@@ -9273,7 +9273,7 @@ Sample text with a \textcolor{red}{word} in red.
 \newlength{\ekd@app@localheight}
 %    \end{macrocode}
 % \begin{macro}{\localappheight}
-% \changes{v1.5}{2023/07/29}{changes the height of the apparatus
+% \changes{v1.5}{2024/05/25}{changes the height of the apparatus
 % criticus}
 % \cs{localappheight}\marg{dimen} can be used to change locally the
 % length of \cs{ekd@app@height} set by the |appheight| option of
@@ -9292,7 +9292,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\addtoappheight}
-% \changes{v1.5}{2023/07/29}{increases or decreases the height of the
+% \changes{v1.5}{2024/05/25}{increases or decreases the height of the
 % apparatus criticus}
 % As the name suggests, in contrast to \cs{localappheight},
 % \cs{addtoappheight}\marg{dimen} is used to increase or decrease
@@ -9579,7 +9579,7 @@ Sample text with a \textcolor{red}{word} in red.
 % The following commands are provided to set and control the maximum
 % number of lines printed on each page.
 % \begin{macro}{\setmaxlines}
-% \changes{v1.5}{2023/07/29}{limits the number of lines per page}
+% \changes{v1.5}{2024/05/25}{limits the number of lines per page}
 % \cs{setmaxlines}\marg{n}, where \meta{n} is a positive integer
 % $\geq 1$, can be used either in the preamble or at any point of the
 % document to set the maximum number of lines to be printed on each
@@ -9590,7 +9590,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\localmaxlines}
-% \changes{v1.5}{2023/07/29}{changes the maximum number of lines
+% \changes{v1.5}{2024/05/25}{changes the maximum number of lines
 % locally}
 % Once a maximum number of lines per page has been set,
 % \cs{localmaxlines}\marg{n} can be used to adjust this number on a
@@ -9603,7 +9603,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\addtomaxlines}
-% \changes{v1.5}{2023/07/29}{adds or subtracts lines from a given page}
+% \changes{v1.5}{2024/05/25}{adds or subtracts lines from a given page}
 % Unlike \cs{localmaxlines}, \cs{addtomaxlines}\meta{n} takes as
 % argument the number of lines one wishes to add or substract from the
 % number that has been set by \cs{setmaxlines}. As a result, \meta{n}
@@ -9616,7 +9616,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\nomaxlines}
-% \changes{v1.5}{2023/07/29}{unsets \cs{setmaxlines}}
+% \changes{v1.5}{2024/05/25}{unsets \cs{setmaxlines}}
 % \cs{nomaxlines} unsets any limit previously set by \cs{setmaxlines}.
 %    \begin{macrocode}
 \def\nomaxlines{\luadirect{tex.sprint(ekdosis.resetlocalmaxlines())}}
@@ -9680,7 +9680,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\App}
-% \changes{v1.5}{2023/07/29}{To be used conjointly with
+% \changes{v1.5}{2024/05/25}{To be used conjointly with
 % \texttt{ekdosis.el}}
 % In contrast to \cs{app}, \cs{App} takes two mandatory arguments and
 % accepts one optional argument like so:
@@ -10157,7 +10157,7 @@ Sample text with a \textcolor{red}{word} in red.
       \unless\ifekdl@nonum\current@ref\fi
       \relax
     }%\hskip .25em}%
-  \else%
+  \else
   \ifbool{al@rlmode}{%
     \edef\lem@app{%
       % \hskip .75em
@@ -10174,30 +10174,58 @@ Sample text with a \textcolor{red}{word} in red.
             \ifekdl@forcedelim\unexpanded\expandafter{\ekd@unit@delim}\fi
           \fi
         \fi
-      \fi%
+      \fi
       \unless\ifekdl@nonum\current@ref\fi%\hskip .25em
       \ifdefined\ekdlr@alt%
-        \ifdefined\ekdlr@post%
-          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        \ifrtl@app
+          \ifdefined\ekdlr@post%
+            \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
           {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}%
             \unexpanded\expandafter{\ekdlr@alt}}%
-        \ifdefined\ekdlr@pre%
-          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          \ifdefined\ekdlr@pre%
+            \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+        \else
+          \ifdefined\ekdlr@pre%
+            \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}%
+            \unexpanded\expandafter{\ekdlr@alt}}%
+          \ifdefined\ekdlr@post%
+            \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        \fi
       \else
-        \ifdefined\ekdlr@post%
-          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        \ifrtl@app
+          \ifdefined\ekdlr@post%
+            \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
           {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}%
             \unexpanded{#2}}%
-        \ifdefined\ekdlr@pre%
-          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          \ifdefined\ekdlr@pre%
+            \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+        \else
+          \ifdefined\ekdlr@pre%
+            \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}%
+            \unexpanded{#2}}%
+          \ifdefined\ekdlr@post%
+            \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        \fi
+      \fi
+      \ifrtl@app
+        \ifdefined\ekdlr@postwit%
+          \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
+        \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
+        \ifdefined\ekdlr@prewit%
+          \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
+        \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
+        \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
+      \else
+        \ifdefined\ekdlr@prewit%
+          \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
+        \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
+        \ifdefined\ekdlr@postwit%
+          \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
+        \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
+        \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
       \fi
-      \ifdefined\ekdlr@postwit%
-        \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
-      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
-      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
-      \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
-      \ifdefined\ekdlr@prewit%
-        \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
       \ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi
     }%
   }%
@@ -10244,10 +10272,10 @@ Sample text with a \textcolor{red}{word} in red.
       \ifdefined\ekdlr@prewit%
         \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
       \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
-      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
-      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
       \ifdefined\ekdlr@postwit%
         \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
+      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
+      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
       \ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi
     }%
   }%
@@ -10294,27 +10322,55 @@ Sample text with a \textcolor{red}{word} in red.
         \unless\ifekdr@nosubsep\unexpanded\expandafter{\ekdr@subsep}\fi
       \fi
       \ifdefined\ekdlr@alt%
-        \ifdefined\ekdlr@post%
-          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        \ifrtl@app
+          \ifdefined\ekdlr@post%
+            \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
           {\textdir TRT\unexpanded\expandafter{\ekd@readingstyle}%
             \unexpanded\expandafter{\ekdlr@alt}}%
-        \ifdefined\ekdlr@pre%
-          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          \ifdefined\ekdlr@pre%
+            \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+        \else
+          \ifdefined\ekdlr@pre%
+            \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          {\textdir TRT\unexpanded\expandafter{\ekd@readingstyle}%
+            \unexpanded\expandafter{\ekdlr@alt}}%
+          \ifdefined\ekdlr@post%
+            \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        \fi
       \else
-        \ifdefined\ekdlr@post%
-          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        \ifrtl@app
+          \ifdefined\ekdlr@post%
+            \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
           {\textdir TRT\unexpanded\expandafter{\ekd@readingstyle}%
             \unexpanded{#2}}%
-        \ifdefined\ekdlr@pre%
-          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          \ifdefined\ekdlr@pre%
+            \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+        \else
+          \ifdefined\ekdlr@pre%
+            \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          {\textdir TRT\unexpanded\expandafter{\ekd@readingstyle}%
+            \unexpanded{#2}}%
+          \ifdefined\ekdlr@post%
+            \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        \fi
+      \fi
+      \ifrtl@app
+        \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
+        \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
+        \ifdefined\ekdlr@postwit%
+          \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
+        \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
+        \ifdefined\ekdlr@prewit%
+          \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
+      \else
+        \ifdefined\ekdlr@prewit%
+          \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
+        \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
+        \ifdefined\ekdlr@postwit%
+          \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
+        \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
+        \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
       \fi
-      \ifdefined\ekdlr@postwit%
-        \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
-      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
-      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
-      \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
-      \ifdefined\ekdlr@prewit%
-        \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
     }%
   }%
   {%
@@ -10346,10 +10402,10 @@ Sample text with a \textcolor{red}{word} in red.
       \ifdefined\ekdlr@prewit%
         \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
       \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
-      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
-      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
       \ifdefined\ekdlr@postwit%
         \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
+      \ifdefined\ekdlr@source\space\getsiglum{\ekdlr@source}\else\fi
+      \ifdefined\ekdlr@resp\space\getsiglum{\ekdlr@resp}\else\fi
     }%
   }%
   \ifekd@mapps
@@ -10609,7 +10665,7 @@ Sample text with a \textcolor{red}{word} in red.
 }
 %    \end{macrocode}
 % \begin{macro}{\SetFootnotes}
-%   \changes{v1.5}{2023/07/29}{footnotes combined into a single
+%   \changes{v1.5}{2024/05/25}{footnotes combined into a single
 %   paragraph} \cs{SetFootnotes}\marg{options} can be used in the
 %   preamble or at any point of the document. |layout=paragraph|
 %   instructs \pkg{ekdosis} to combine all footnotes into a single
@@ -10840,7 +10896,7 @@ Sample text with a \textcolor{red}{word} in red.
 % \end{macro}
 % \paragraph{Lacunae}
 % \begin{macro}{\ilabel}
-% \changes{v1.5}{2023/07/29}{recalls and sets the ending label of
+% \changes{v1.5}{2024/05/25}{recalls and sets the ending label of
 % lemmas used to mark lacunae in witnesses} When \cs{lem} has been
 % used with the optional argument |ilabel=<label>|,
 % \cs{ilabel}\marg{label} must be used to mark the point where the
@@ -11175,7 +11231,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\ekdEOprint}
-% \changes{v1.5}{2023/07/29}{Sets headers and footers on
+% \changes{v1.5}{2024/05/25}{Sets headers and footers on
 % \enquote{paired} facing pages}
 % To set headers and footers on \enquote{paired} facing pages,
 % \cs{ekdEOprint} accepts two mandatory, self-evident arguments, like
@@ -11215,7 +11271,7 @@ Sample text with a \textcolor{red}{word} in red.
 % counter to set the value of the page numbers. This counter should be
 % incremented every two pages.
 % \begin{counter}{pairedpage}
-% \changes{v1.5}{2023/07/29}{A counter incremented every two pages}
+% \changes{v1.5}{2024/05/25}{A counter incremented every two pages}
 % |pairedpage| is first set as a global counter:---
 %    \begin{macrocode}
 \newcounter{pairedpage}
@@ -11223,19 +11279,19 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{counter}
 % \begin{macro}{\setpairedpagenum}
-%   \changes{v1.5}{2023/07/29}{sets the same page number on paired
+%   \changes{v1.5}{2024/05/25}{sets the same page number on paired
 %   pages} \cs{setpairedpagenum}\marg{number} is used just ahead of
 %   the alignment environment to set the number of the first left-hand
 %   paired page.
 % \begin{macro}{\setpairedpage}
-%   \changes{v1.5}{2023/07/29}{sets the page number of the first paired
+%   \changes{v1.5}{2024/05/25}{sets the page number of the first paired
 %   page} \cs{setpairedpage} is an argument-less command meant to be
 %   issued in commands used to set headers or footers before
 %   \cs{thepage}. This command has the counter |pairedpage|
 %   incremented on right-hand pages only, and sets |page| $\leftarrow$
 %   |pairedpage| on every page.
 % \begin{macro}{\resetpagenumber}
-%   \changes{v1.5}{2023/07/29}{resets normal running page numbers}
+%   \changes{v1.5}{2024/05/25}{resets normal running page numbers}
 %   \cs{resetpagenumber} must be used right out of \enquote{mirrored}
 %   paired pages alignment environments. This argument-less command
 %   corrects any numbering error on the page following the edition
-- 
cgit v1.2.3

