From 9ad3d75b3ccad6ce150ac7eed6eb3ec973651a02 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Sun, 15 May 2022 11:36:36 +0200
Subject: removed the need of {} or \ after \ekdpb*. improved the \ekddot
 trick. removed the braces around the contents of \ekd@note added a second
 call texpatttotei() to process any remnant patterns

---
 ekdosis.dtx | 150 +++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 87 insertions(+), 63 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index da016a7..7a16446 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -61,7 +61,7 @@ along with this program.  If not, see
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{ekdosis}
 %<*package>
-    [2022/05/09 v1.5-dev Typesetting TEI xml-compliant critical editions]
+    [2022/05/15 v1.5-dev Typesetting TEI xml-compliant critical editions]
 %</package>
 %<*driver>
 \begin{filecontents}[noheader,overwrite]{bibdata.xml}
@@ -6156,7 +6156,7 @@ subtype="arabtex">'inna 'abI kAna mina
 % \paragraph{Conditional page breaks}
 % \phts\label{ref:ekdpb} \DescribeMacro{\ekdpb}\DescribeMacro{\ekdpb*}
 % \cs{ekdpb}\oarg{page no}\marg{line no}
-% \cs{ekdpb*}|{}| \cs{ekdpb*}|\|
+% \cs{ekdpb*}|{}| \cs{ekdpb*}
 % \newfeature[v1.2]\\
 % One way to avoid this inconvenience is to use \cs{ekdpb} instead of
 % the standard \cs{pagebreak} command provided by \LaTeX\ to insert
@@ -6269,7 +6269,7 @@ subtype="arabtex">'inna 'abI kAna mina
 
 \makeatletter
 \newcommand{\ekddot}{%
-  \ltx@ifnextchar{.}{\xspace}{.\xspace}}
+  \ltx@ifnextchar@nospace{.}{\xspace}{.\xspace}}
 \makeatother
 
 \DeclareApparatus{default}[ehook=.]
@@ -6282,9 +6282,9 @@ subtype="arabtex">'inna 'abI kAna mina
 % \begin{remarks}
 % \item Line~2: The \pkg{xspace} package is needed for \cs{xspace} is
 %   used by the \cs{ekddot} command that is defined at l.~6.
-% \item Line~7: \cs{ltx@ifnextchar} is part of the \pkg{ltxcmds}
-%   package which is loaded by \pkg{ekdosis}. As this command uses a
-%   private control sequence, it must be found within
+% \item Line~7: \cs{ltx@ifnextchar@nospace} is part of the
+%   \pkg{ltxcmds} package which is loaded by \pkg{ekdosis}. As this
+%   command uses a private control sequence, it must be found within
 %   \cs{makeatletter} \dots\ \cs{makeatother}.
 % \item Line~10: \cs{ekddot} will only work with multiple-layer
 %   apparatus criticus. Therefore, \cs{DeclareAppa{\allowbreak}ratus}
@@ -8167,6 +8167,7 @@ Sample text with a \textcolor{red}{word} in red.
 \newif\if@pkg@footins
 \newif\if@pkg@keyfloat
 \newif\if@pkg@fitapp
+\newif\if@pkg@breakable
 \newif\if@pkg@ekddivs
 \newif\if@parnotesroman
 \newif\if@pkg@parnotes
@@ -8176,10 +8177,12 @@ Sample text with a \textcolor{red}{word} in red.
   choice layout = {float = {\@pkg@floattrue},
     footins = {\@pkg@floatfalse\@pkg@footinstrue},
     keyfloat = {\@pkg@floatfalse\@pkg@keyfloattrue},
-    fitapp = {\@pkg@floatfalse\@pkg@fitapptrue}},
+    fitapp = {\@pkg@floatfalse\@pkg@fitapptrue},
+    breakable = {\@pkg@floatfalse\@pkg@fitapptrue\@pkg@breakabletrue}},
   initial layout = float,
   unknown-choice layout = \PackageError{ekdosis}{unknown
-    layout=#1}{`layout' must be either `float' or `footins'.},
+    layout=#1}{`layout' must be either `float', `footins', `keyfloat',
+    `fitapp' or `breakable'.},
   choice divs = {ekdosis = {\@pkg@ekddivstrue},
     latex = {\@pkg@ekddivsfalse
       \AtBeginDocument{\luadirect{ekdosis.setekddivsfalse()}}}},
@@ -8237,7 +8240,11 @@ Sample text with a \textcolor{red}{word} in red.
 \fi
 \if@pkg@fitapp
   \RequirePackage{tcolorbox}
-  \tcbuselibrary{fitting,skins} %,breakable}
+  \tcbuselibrary{fitting,skins}
+\fi
+\if@pkg@breakable
+  \RequirePackage{tcolorbox}
+  \tcbuselibrary{fitting,skins,breakable}
 \fi
 \RequirePackage{refcount}
 \RequirePackage{zref-user}
@@ -8263,7 +8270,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \paragraph{\textsf{ekdosis} Symbol}
 % \begin{macro}{\eKd}
-% \changes{v1.5}{2022/05/09}{Prints \textsf{ekdosis} indentifying
+% \changes{v1.5}{2022/05/15}{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.
@@ -8526,7 +8533,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}{2022/05/09}{direct insertion of empty elements in the
+% \changes{v1.5}{2022/05/15}{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
@@ -8541,7 +8548,7 @@ Sample text with a \textcolor{red}{word} in red.
 % \end{macro}
 % \end{macro}
 % \begin{macro}{\getTEIxmlid}
-% \changes{v1.5}{2022/05/09}{returns \texttt{TEI xml:ids} from a
+% \changes{v1.5}{2022/05/15}{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
@@ -8723,7 +8730,9 @@ Sample text with a \textcolor{red}{word} in red.
 \NewDocumentCommand{\ekdpb}{s o m}{%
   \IfBooleanTF{#1}
   {\ifekd@showpb\marginpar{\ekd@hpbmk}\fi
-    \pagebreak}
+    \pagebreak
+    \@ifnextchar\bgroup{}{#3}%
+  }
   {%
     \def\@tmpoarg{#2}%
     \def\@tmpmarg{#3}%
@@ -9014,7 +9023,7 @@ Sample text with a \textcolor{red}{word} in red.
 \if@pkg@fitapp
   \newtcboxfit{\ekd@fitapp}{%
     blankest,
-    % breakable,
+    \if@pkg@breakable breakable\fi,
     fit basedim = \f@size pt,
     fit fontsize macros,
     fit height from=0pt to \ekd@app@height,
@@ -9022,6 +9031,15 @@ Sample text with a \textcolor{red}{word} in red.
     float=!b}
 \fi
 %    \end{macrocode}
+% Then \cs{ekd@breakable} for |layout=breakable|:---
+%    \begin{macrocode}
+ % \if@pkg@breakable
+ %   \newtcboxfit{\ekd@breakable}{%
+ %     blankest,
+ %     breakable,
+ %     float=!b}
+ % \fi
+%    \end{macrocode}
 % Finally two commands are used to actually insert the apparatus
 % depending on the value set in the |layout| global option.
 %    \begin{macrocode}
@@ -9082,6 +9100,9 @@ Sample text with a \textcolor{red}{word} in red.
   \if@pkg@fitapp
     \ekd@fitapp{\ekd@insert@apparatus}%
   \fi
+  % \if@pkg@breakable
+  %   \ekd@breakable{\ekd@insert@apparatus}%
+  % \fi
 }
 %    \end{macrocode}
 % Before inserting any new entry, \cs{add@apparatus} calls
@@ -9937,12 +9958,12 @@ Sample text with a \textcolor{red}{word} in red.
 % defined above.
 %    \begin{macrocode}
 \NewDocumentCommand{\ekd@note}{O{} m}{%
-  \bgroup%
+  \bgroup
   \ekvset{ekd@note}{#1}%
   \edef\note@contents{%
     \ekvifdefinedNoVal{ekd@note}{pre}{}{%
       \unexpanded\expandafter{\pre@value}}%
-    {\unexpanded{#2}}%
+    \unexpanded{#2}%
     \ekvifdefinedNoVal{ekd@note}{post}{}{%
       \unexpanded\expandafter{\post@value}}%
   }%
@@ -9951,7 +9972,7 @@ Sample text with a \textcolor{red}{word} in red.
   \else%
   \append@app{\note@contents}%
   \fi%
-  \egroup%
+  \egroup
 }
 \NewDocumentCommand{\ekd@note@star}{O{} m}{%
   \bgroup
@@ -10118,7 +10139,7 @@ Sample text with a \textcolor{red}{word} in red.
 % \end{macro}
 % \paragraph{Lacunae}
 % \begin{macro}{\ilabel}
-% \changes{v1.5}{2022/05/09}{recalls and sets the ending label of
+% \changes{v1.5}{2022/05/15}{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
@@ -10298,7 +10319,8 @@ Sample text with a \textcolor{red}{word} in red.
   \begin{paracol}[\lcols@num]*{\tcols@num}
   \fi
   }
-  {\end{paracol}
+  {\if@pkg@breakable\flushpage\fi
+  \end{paracol}
   \iftei@export\luadirect{ekdosis.export_coldata_totei()}\fi
   \ifekd@flushapp
     \luadirect{ekdosis.newalignment("reset")}
@@ -10433,7 +10455,7 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\ekdEOprint}
-% \changes{v1.5}{2022/05/09}{Sets headers and footers on
+% \changes{v1.5}{2022/05/15}{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
@@ -10473,7 +10495,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}{2022/05/09}{A counter incremented every two pages}
+% \changes{v1.5}{2022/05/15}{A counter incremented every two pages}
 % |pairedpage| is first set as a global counter:---
 %    \begin{macrocode}
 \newcounter{pairedpage}
@@ -10481,19 +10503,19 @@ Sample text with a \textcolor{red}{word} in red.
 %    \end{macrocode}
 % \end{counter}
 % \begin{macro}{\setpairedpagenum}
-%   \changes{v1.5}{2022/05/09}{sets the same page number on paired
+%   \changes{v1.5}{2022/05/15}{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}{2022/05/09}{sets the page number of the first paired
+%   \changes{v1.5}{2022/05/15}{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}{2022/05/09}{resets normal running page numbers}
+%   \changes{v1.5}{2022/05/15}{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
@@ -12292,6 +12314,7 @@ local function textotei(str)
    str = section_totei(str)
    str = icitetotei(str)
    str = cmdtotei(str)
+   str = texpatttotei(str)
    str = self_close_tags(str)
    str = partotei(str)
    if ekddivs
@@ -12748,49 +12771,50 @@ function ekdosis.mkenv()
       if isfound(texts_w_apparatus, aligned_texts[i].text)
       then
 	 table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{+b}"
-			 .."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}"
-			 .."\\par"
-			 .."\\EkdosisColStart"
-			 .."\\EkdosisOn#1"
-		         .."}{\\EkdosisOff"
-			 .."\\EkdosisColStop"
-		         .."\\end{nthcolumn}"
-			 .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
-			 .. aligned_texts[i].column
-			 ..", \\luastringN{\\par#1\\par})}\\fi"
-			 .."}")
+		      .."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}"
+		      .."\\csname if@pkg@breakable\\endcsname\\raggedbottom\\fi"
+		      .."\\par"
+		      .."\\EkdosisColStart"
+		      .."\\EkdosisOn#1"
+		      .."}{\\EkdosisOff"
+		      .."\\EkdosisColStop"
+		      .."\\end{nthcolumn}"
+		      .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
+		      .. aligned_texts[i].column
+		      ..", \\luastringN{\\par#1\\par})}\\fi"
+		      .."}")
 	 table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{+b}"
-			 .."{\\begin{nthcolumn*}{".. aligned_texts[i].column.."}[]"
-			 .."\\par"
-			 .."\\EkdosisColStart"
-			 .."\\EkdosisOn#1"
-		         .."}{\\EkdosisOff"
-			 .."\\EkdosisColStop"
-		         .."\\end{nthcolumn*}"
-			 .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
-			 .. aligned_texts[i].column
-			 ..", \\luastringN{\\par#1\\par})}\\fi"
-			 .."}")
+		      .."{\\begin{nthcolumn*}{".. aligned_texts[i].column.."}[]"
+		      .."\\par"
+		      .."\\EkdosisColStart"
+		      .."\\EkdosisOn#1"
+		      .."}{\\EkdosisOff"
+		      .."\\EkdosisColStop"
+		      .."\\end{nthcolumn*}"
+		      .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
+		      .. aligned_texts[i].column
+		      ..", \\luastringN{\\par#1\\par})}\\fi"
+		      .."}")
       else
 	 table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{+b}"
-			 .."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}"
-			 .."\\par"
-			 .."#1"
-		         .."}{\\end{nthcolumn}"
-			 .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
-			 .. aligned_texts[i].column
-			 ..", \\luastringN{\\par#1\\par})}\\fi"
-			 .."}")
+		      .."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}"
+		      .."\\par"
+		      .."#1"
+		      .."}{\\end{nthcolumn}"
+		      .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
+		      .. aligned_texts[i].column
+		      ..", \\luastringN{\\par#1\\par})}\\fi"
+		      .."}")
 	 table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{+b}"
-			 .."{\\begin{nthcolumn*}{"..aligned_texts[i].column.."}[]"
-			 .."\\par"
-			 .."#1"
-			 .."}{"
-		         .."\\end{nthcolumn*}"
-			 .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
-			 .. aligned_texts[i].column
-			 ..", \\luastringN{\\par#1\\par})}\\fi"
-			 .."}")
+		      .."{\\begin{nthcolumn*}{"..aligned_texts[i].column.."}[]"
+		      .."\\par"
+		      .."#1"
+		      .."}{"
+		      .."\\end{nthcolumn*}"
+		      .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata("
+		      .. aligned_texts[i].column
+		      ..", \\luastringN{\\par#1\\par})}\\fi"
+		      .."}")
       end
       forbid_xmlid = false
       if aligned_texts[i].attribute ~= ""
-- 
cgit v1.2.3

