From 5f0be4a846c6df990032c3a7f8e0f9a845127963 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Mon, 5 Oct 2020 19:53:33 +0200
Subject: documenting subvariation

---
 ekdosis.dtx | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 94 insertions(+), 9 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 20fbdb3..7531487 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -254,6 +254,7 @@ along with this program.  If not, see
 % Peter and John Story:
 \DeclareWitness{pjA}{A}{Manuscript A Call No 123}
 \DeclareWitness{pjB}{B}{Manuscript B Call No 456}
+\DeclareWitness{pjC}{C}{Manuscript C Call No 789}
 % Caesar's Gallic War:
 \DeclareWitness{cA}{A}{\emph{Bongarsianus} 81}[
                msName=Bongarsianus,
@@ -1723,6 +1724,84 @@ yesterday.
 %</example>
 % \fi
 %
+% \subsection{Indicating Subvariation in Apparatus Entries}
+% \label{sec:indic-subv-appar}
+% It must be noted that grouping readings so as to keep emphasis on
+% subvariation, regardless of its cause, is entirely optional.
+% Furthermore, the applicability of this technique is limited to the
+% \texttt{TEI xml} output as it helps the machines to understand a
+% grouping otherwise immediately accessible to human mind from the
+% information that is available in well-written
+% apparatus. \pkg{ekdosis} provides two ways of expressing
+% subvariation.
+%
+% \subsubsection{Implicit Grouping by Nesting Entries}
+% \label{sec:impl-group-nest}
+% Because apparatus entries may nest recursively, the \cs{app} command
+% may be used to group similar readings.
+%
+% \danger However, for nesting to work, the |alt| optional argument
+% must be used in every \cs{lem} and \cs{rdg} command involved in the
+% nesting. This rule applies to both parent and child commands, as
+% demonstrated in the following example:---
+% 
+% \iffalse
+%<*example>
+% \fi
+\begin{minted}[linenos=false]{latex}
+As I was walking home through Times Square, I saw my friend
+\app{
+  \lem[wit={A,B}, alt={Peter\---yesterday}]{Peter at the
+    \app{
+      \lem[wit=A, alt=station]{station}
+      \rdg[wit=B, alt=pub]{bookstore}}
+    yesterday}
+  \rdg[wit=C, alt={John at the bookstore this evening}]{John at the
+    bookstore this evening}}.
+\end{minted}
+% \iffalse
+%</example>
+% \fi
+%
+% PDF output:---
+% \medskip
+% 
+% \needspace{7\baselineskip}
+% \resetlinenumber
+% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
+%   \begin{specimen}
+%    As I was walking home through Times Square, I saw my friend
+%    \app{
+%      \lem[wit={pjA,pjB}, alt={Peter\---yesterday}]{Peter at the
+%        \app{
+%          \lem[wit=pjA, alt=station]{station}
+%          \rdg[wit=pjB, alt=pub]{bookstore}}
+%        yesterday}
+%      \rdg[wit=pjC, alt={John at the bookstore this evening}]{John at
+%      the bookstore this evening}}.
+%   \end{specimen}
+% \end{alignment}
+%
+% \texttt{TEI xml} output:---
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{minted}[linenos=false]{xml}
+<p>As I was walking home through Times Square, I saw my
+friend 
+<app>
+  <lem wit="#A #B">Peter at the 
+  <app>
+    <lem wit="#A">station</lem>
+    <rdg wit="#B">bookstore</rdg>
+  </app>yesterday</lem>
+  <rdg wit="#C">John at the bookstore this evening</rdg>
+</app>.</p>
+\end{minted}
+% \iffalse
+%</example>
+% \fi
 % \section{Emendations and Conjectures}
 % \label{sec:emendations-conjectures}
 % From a technical standpoint, \enquote{conjectures} are readings that
@@ -6579,7 +6658,13 @@ Sample text with a \textcolor{red}{word} in red.
 }
 %    \end{macrocode}
 % \begin{macro}{\rdgGrp}
-% \changes{v1.1}{2020/10/03}{new command for subvariation}
+% \changes{v1.1}{2020/10/03}{new macro for grouping readings}
+% \cs{rdgGrp}\oarg{option}\marg{lemma and/or readings} may be used to
+% group readings so as to indicate subvariation in apparatus
+% entries. This command is expected inside \cs{app}|{}|, and takes as
+% argument readings to be grouped introduced by means of \cs{lem}
+% and/or \cs{rdg} commands.  It further accepts |type| as an optional
+% key-value argument to describe the type of grouping.
 %    \begin{macrocode}
 \NewDocumentCommand{\rdgGrp}{O{} > {\TrimSpaces } m}{%
   \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#2}))}%
@@ -7902,12 +7987,12 @@ local function rdgGrp_totei(str)
 	      function(bkslash, cmd, opt, arg)
 		 opt = string.sub(opt, 2, -2)
 		 arg = string.sub(arg, 2, -2)
-		 -- teiwit = get_attr_value(opt, "wit")
-		 -- if teiwit ~= "" then teiwit = " wit=\""..ekdosis.getsiglum(teiwit, "tei").."\"" else end
-		 -- teisource = get_attr_value(opt, "source")
-		 -- if teisource ~= "" then teisource = " source=\""..ekdosis.getsiglum(teisource, "tei").."\"" else end
-		 -- teiresp = get_attr_value(opt, "resp")
-		 -- if teiresp ~= "" then teiresp = " resp=\""..ekdosis.getsiglum(teiresp, "tei").."\"" else end
+		 teiwit = get_attr_value(opt, "wit")
+		 if teiwit ~= "" then teiwit = " wit=\""..ekdosis.getsiglum(teiwit, "tei").."\"" else end
+		 teisource = get_attr_value(opt, "source")
+		 if teisource ~= "" then teisource = " source=\""..ekdosis.getsiglum(teisource, "tei").."\"" else end
+		 teiresp = get_attr_value(opt, "resp")
+		 if teiresp ~= "" then teiresp = " resp=\""..ekdosis.getsiglum(teiresp, "tei").."\"" else end
 		 teitype = get_attr_value(opt, "type")
 		 if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end
 		 if opt == ""
@@ -7915,8 +8000,8 @@ local function rdgGrp_totei(str)
 		    return rdgGrp_totei(string.format("<%s>%s</%s>",
 						       cmd, arg, cmd))
 		 else
-		    return rdgGrp_totei(string.format("<%s%s>%s</%s>",
-						       cmd, teitype, arg, cmd))
+		    return rdgGrp_totei(string.format("<%s%s%s%s%s>%s</%s>",
+						       cmd, teiwit, teisource, teiresp, teitype, arg, cmd))
 		 end
    end)
    return str
-- 
cgit v1.2.3

