From 01b4f2311a844a702ca390deb66ee1100e64aed9 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Fri, 12 Mar 2021 18:53:17 +0100
Subject: 'verse option' -> 'poetry=verse'. new hook 'initialrule'. latex-dev
 needed subtle insertions of \leavevmode. improved ekdosis.appout()

---
 ekdosis.dtx | 165 +++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 114 insertions(+), 51 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 3e8181a..9e1ead5 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -962,8 +962,8 @@ along with this program.  If not, see
 % \section{The Basics of \pkg{ekdosis}}
 % \label{sec:ekdosis-basics}
 %
-%\subsection{Loading the Package\---General Options}
-%\label{sec:load-general-options}
+% \subsection{Loading the Package\---General Options}
+% \label{sec:load-general-options}
 %
 % \pkg{ekdosis} is loaded in the preamble like so:---
 % \iffalse
@@ -1010,14 +1010,13 @@ along with this program.  If not, see
 % \danger It must be noted that the two styles are mutually exclusive.
 % \vskip\baselineskip
 %
-% \DescribeOption{verse}\label{ref:verse-opt}
-% |verse|$=$\verb+true|false+
-% \hfill\tcboxverb{Default: false}\\
-% This named argument does not need a value as it defaults to |true|
-% if it is used. |verse| instructs \pkg{ekdosis} to load and use the
-% facilites supplied by the \pkg{verse} package for typesetting lines
-% of poetry. The \env{ekdverse} environment must then be used instead
-% of the \env{verse} environment that is provided by the \pkg{verse}
+% \DescribeOption{poetry}\label{ref:poetry-opt}
+% |poetry|$=$\verb+verse+
+% \hfill\tcboxverb{Default: not set}\\
+% |poetry=verse| instructs \pkg{ekdosis} to load and use the facilites
+% supplied by the \pkg{verse} package for typesetting lines of
+% poetry. The \env{ekdverse} environment must then be used instead of
+% the \env{verse} environment that is provided by the \pkg{verse}
 % package as described below in \vref{sec:poetry}.
 %
 % \DescribeOption{parnotes}\label{ref:parnotes-opt}
@@ -2948,7 +2947,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
 % reference to line numbers. By default, it is |~|, namely an
 % unbreakable space. As an example, |postrefnum=\hskip 0.5em| will
 % insert a \unit[0.5]{em} space between the numerals and the beginning
-% of all subsequent notes.
+% of all subsequent notes.\\
 % \DescribeOption{lemmastyle} |lemmastyle|$=$\meta{command}
 % \hfill\tcboxverb{Default: not set}\\
 % \newfeature[v1.2] |lemmastyle| can be used to set the family, series
@@ -2956,7 +2955,19 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
 % criticus. For example, |lemmastyle=|\cs{bfseries} will print all
 % instances of lemma text in bold while
 % |lemmastyle=|\cs{color}|{blue}| will print them in blue.
-%
+% \DescribeOption{initialrule} |initialrule|$=$\meta{command}
+% \label{ref:initialrule}\hfill\bgroup\footnotesize
+% \tcboxverb{Default: \rule{0.4\columnwidth}{0.4pt} (initially not set)}%
+% \egroup
+% \newfeature[v1.2] |initialrule| draws a separating rule between the
+% edition text and all subsequent layers of critical notes. Of course,
+% this option only makes sense when multiple-layer apparatus criticus
+% are set. Therefore, it has no effect on single-layer apparatus
+% criticus.\\
+% \DescribeOption{noinitialrule}\hfill\tcboxverb{Default: not set}\\
+% This is a no-value option. It removes any previously set
+% |initialrule|.
+% 
 % \subsection{Single-Layer Apparatus Criticus}
 % \label{sec:single-layer-app}
 % \paragraph{Specific Commands}
@@ -3170,25 +3181,37 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
 % \iffalse
 %<*example>
 % \fi
-\begin{minted}[linenos=false]{latex}
+\begin{minted}{latex}
 \SetHooks{
-  refnumstyle=\normalfont
+  refnumstyle=\normalfont,
+  initialrule=\rule{0.7in}{0.4pt}
 }
 \DeclareApparatus{testium}[
   sep={] },
   delim=\hskip 1em,
-  rule=\rule{0.7in}{0.4pt}
+  norule
 ]
 \DeclareApparatus{default}[
   sep={: },
   delim=\hskip 1em,
-  norule
+  rule=\relax
 ]
 \end{minted}
 % \iffalse
 %</example>
 % \fi
-% 
+%
+% \begin{remarks}
+% \item The general hook \texttt{initialrule} used here (l.~3) is
+%   described above \vpageref{ref:initialrule}.
+% \item \cs{relax} (l.~13) is a \TeX\ primitive that instructs to do
+%   nothing. Therefore, |rule=\relax| is not strictly equivalent to
+%   |norule|: with the former, \cs{relax} removes the rule but leaves
+%   untouched the subsequent carriage return: as a result, the layers
+%   are visually separated from one another by a blank line. With the
+%   latter everything is removed, carriage return included.
+% \end{remarks}
+%
 % \paragraph{Limiting the Number of Entries per Page}
 % \label{ref:maxentries}
 % In some instances, it can be useful to set a limit to the number of
@@ -3442,7 +3465,7 @@ the American Continent</emph>, II.61--2.</note></p>
 \begin{minted}[linenos=false]{latex}
 This is some \app{
   \lem[alt=dummy]{\note[type=fontium, labelb=bnote, labele=enote,
-    lem=dummy... command]{Text of the note}
+    lem=dummy... command]{Text of the note.}
     dummy}
   \rdg{pseudo}}
 text to demonstrate how to insert a note in the argument of the
@@ -3461,7 +3484,7 @@ text to demonstrate how to insert a note in the argument of the
 %   \begin{specimen}
 % This is some \app{
 %   \lem[alt=dummy]{\note[type=fontium, labelb=bnote, labele=enote,
-%     lem=dummy... command]{Text of the note}
+%     lem=dummy... command]{Text of the note.}
 %     dummy}
 %   \rdg{pseudo}}
 % text to demonstrate how to insert a note in the argument of the
@@ -3481,7 +3504,7 @@ text to demonstrate how to insert a note in the argument of the
   <anchor xml:id="bnote" />dummy</lem>
   <note type="fontium"
   target="#range(right(bnote),left(enote))">Text of the
-  note</note>
+  note.</note>
   <rdg>pseudo</rdg>
 </app>text to demonstrate how to insert a note in the
 argument of the 
@@ -6233,6 +6256,9 @@ Sample text with a \textcolor{red}{word} in red.
   store refnumstyle = \ekd@refnumstyle,
   store postrefnum = \ekd@postrefnum,
   store lemmastyle = \ekd@lemmastyle,
+  code initialrule = \def\ekd@initial@rule{#1\NLS},
+  default initialrule = \rule{0.4\columnwidth}{0.4pt},
+  noval noinitialrule = \undef\ekd@initial@rule,
   initial appfontsize = \footnotesize,
   initial refnumstyle = \bfseries,
   initial postrefnum = ~,
@@ -6802,11 +6828,14 @@ Sample text with a \textcolor{red}{word} in red.
 % documented.
 %    \begin{macrocode}
 \newcommand*{\NLS}{%
-  \par%
-  \nobreak%
-  \vspace{-\parskip}%
-  \noindent%
-  \ignorespaces}
+  \nobreak\@normalcr\relax
+  % \par
+  % \nobreak
+  % \vspace{-\parskip}%
+  % \leavevmode
+  % \noindent
+  % \ignorespaces
+}
 %    \end{macrocode}
 % \end{macro}
 % This boolean is used to test if a given entry is to be preceded by a
@@ -6823,34 +6852,53 @@ Sample text with a \textcolor{red}{word} in red.
 %    \begin{macrocode}
 \newif\ifekd@inside@app
 \def\add@@apparatus{%
-  \if@pkg@parnotes\parnotes\else\fi%
-  \if@pkg@footins%
-  \bgroup%
-  \ifrtl@app\setRL\else\setLR\fi%
+  \if@pkg@parnotes\parnotes\else\fi
+  \if@pkg@footins
+  \bgroup
+    \unless\ifekd@mapps
+      \ifrtl@app\pardir TRT\leavevmode\textdir TRT\else
+        \pardir TLT\leavevmode\textdir TLT\fi
+    \fi
   \blfootnote{%
-    \if@pkg@parnotes%
-    \if@parnotesroman%
-    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi%
-    \parnoteclear\else\fi%
+    \if@pkg@parnotes
+    \if@parnotesroman
+    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi
+    \parnoteclear\else\fi
     \ekd@inside@apptrue
-    \footnotesize\apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi%
+    \ekd@appfontsize
+    \ifekd@mapps
+      \ifdefined\ekd@initial@rule
+        \ekd@initial@rule
+      \fi
+    \fi
+    \apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi
     \ekd@inside@appfalse
     \if@pkg@parnotes\parnotes\parnotereset\else\fi
   }%
-  \egroup%
-  \fi%
-  \if@pkg@float%
-  \keyparbox[!b]{}{\ifrtl@app\setRL\else\setLR\fi%
-    \if@pkg@parnotes%
-    \if@parnotesroman%
-    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi%
-    \parnoteclear\else\fi%
+  \egroup
+  \fi
+  \if@pkg@float
+  \keyparbox[!b]{}{%
+    \unless\ifekd@mapps
+      \ifrtl@app\pardir TRT\leavevmode\textdir TRT\else
+        \pardir TLT\leavevmode\textdir TLT\fi
+    \fi
+    \if@pkg@parnotes
+    \if@parnotesroman
+    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi
+    \parnoteclear\else\fi
     \ekd@inside@apptrue
-    \ekd@appfontsize\apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi%
+    \ekd@appfontsize
+    \ifekd@mapps
+      \ifdefined\ekd@initial@rule
+        \ekd@initial@rule
+      \fi
+    \fi
+    \apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi
     \ekd@inside@appfalse
-    \if@pkg@parnotes\parnotes\parnotereset\else\fi%
+    \if@pkg@parnotes\parnotes\parnotereset\else\fi
   }%
-  \fi%
+  \fi
 }
 %    \end{macrocode}
 % Before inserting any new entry, \cs{add@apparatus} calls
@@ -9924,7 +9972,7 @@ function ekdosis.appout()
       local output = {}
       if next(apparatuses) == nil then
 	 -- table.insert(output, "BEGIN")
-	 table.insert(output, "\\noindent\\csname ekd@default@rule\\endcsname\\NLS")
+	 table.insert(output, "\\csname ekd@default@rule\\endcsname\\NLS")
 	 table.insert(output, "\\csname ekd@begin@apparatus\\endcsname\\ignorespaces")
 --	 table.insert(output, "\\noindent ")
 	 for i in string.gmatch(t,
@@ -9939,6 +9987,7 @@ function ekdosis.appout()
 	 end
 	 -- table.insert(output, "END")
       else
+	 local appinserted = false
 	 local n = 1
 	 while apparatuses[n]
 	 do
@@ -9953,16 +10002,19 @@ function ekdosis.appout()
 	       table.insert(output, "\\bgroup{}")
 	       if apparatuses[n].direction == "LR"
 	       then
-		  table.insert(output, "\\pardir TLT\\textdir TLT{}")
+		  table.insert(output, "\\pardir TLT\\leavevmode\\textdir TLT{}")
 	       elseif apparatuses[n].direction == "RL"
 	       then
-		  table.insert(output, "\\pardir TRT\\textdir TRT{}")
+		  table.insert(output, "\\pardir TRT\\leavevmode\\textdir TRT{}")
 	       end
 	       if apparatuses[n].rule == "none"
 	       then
 		  if n > 1
 		  then
-		     table.insert(output, "\\NLS{}")
+		     if appinserted
+		     then
+			table.insert(output, "\\NLS{}")
+		     end
 		  else
 		     table.insert(output, "\\noindent ")
 		  end
@@ -9970,7 +10022,12 @@ function ekdosis.appout()
 	       then
 		  if n > 1
 		  then
-		     table.insert(output, "\\NLS{}" .. apparatuses[n].rule .. "\\NLS{}")
+		     if appinserted
+		     then
+			table.insert(output, "\\NLS{}" .. apparatuses[n].rule .. "\\NLS{}")
+		     else
+			table.insert(output, apparatuses[n].rule .. "\\NLS{}")
+		     end
 		  else
 --		     table.insert(output, "\\noindent ")
 		     table.insert(output, apparatuses[n].rule .. "\\NLS{}")
@@ -9978,7 +10035,12 @@ function ekdosis.appout()
 	       else
 		  if n > 1
 		  then
-		     table.insert(output, "\\NLS\\csname ekd@default@rule\\endcsname\\NLS{}")
+		     if appinserted
+		     then
+			table.insert(output, "\\NLS\\csname ekd@default@rule\\endcsname\\NLS{}")
+		     else
+			table.insert(output, "\\csname ekd@default@rule\\endcsname\\NLS{}")
+		     end
 		  else
 --		     table.insert(output, "\\noindent ")
 		     table.insert(output, "\\csname ekd@default@rule\\endcsname\\NLS{}")
@@ -10004,6 +10066,7 @@ function ekdosis.appout()
 					 ..curcol.."%-"..n..">")
 	       do
 		  table.insert(output, i)
+		  appinserted = true
 	       end
 	       if apparatuses[n].ehook ~= ""
 	       then
-- 
cgit v1.2.3

