From dc6ffb9a2446468237848fb1d833335e6c98e360 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Mon, 1 Apr 2019 17:34:18 +0200
Subject: bugfix: duplicate apparatuses

---
 ekdosis.dtx | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index ede20ef..c01189a 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -394,12 +394,20 @@ idno={}, msName={}][3]{%
 \newif\ifekd@isinapp
 \providebool{al@rlmode}
 \newcounter{ekd@lab}
+\def\unconditional@appin#1{%
+  \luadirect{ekdosis.appin(
+    \luastring{<\zref@extract{ekd:\theekd@lab}{abspage}>},
+    "no")}%
+  \luadirect{ekdosis.appin(\luastringN{#1}, "no")}%
+  \luadirect{ekdosis.appin(
+    \luastring{</\zref@extract{ekd:\theekd@lab}{abspage}>},
+    "yes")}%
+}
 \def\blfootnote{\gdef\@thefnmark{\relax}\@footnotetext}
 \def\add@@apparatus{%
   % \blfootnote{\apparatus}%
   \if@pkg@parnotes\parnotes\else\fi%
   \keyparbox[b!]{}{%
-    \rule{5cm}{0.5pt}\\
     \if@pkg@parnotes%
     \if@parnotesroman%
     \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi%
@@ -407,10 +415,11 @@ idno={}, msName={}][3]{%
     \footnotesize\apparatus%
     \if@pkg@parnotes\parnotes\parnotereset\else\fi%
   }%
+  \unconditional@appin{\rule{5cm}{0.5pt}\newline}
 }
 \def\add@apparatus{%
   \notbool{ekd@started}{\add@@apparatus%
-    \setbool{ekd@started}{true}}
+    \global\setbool{ekd@started}{true}}
   {\test@apparatus%
     \ifbool{do@app}{\add@@apparatus}{}}%
 }
@@ -532,7 +541,8 @@ choice nolem={false,,true}][1]{%
 }
 \NewDocumentEnvironment{ekdosis}{+b}{%
   \begin{linenumbers}
-    \EkdosisStart%
+    \ifbool{ekd@started}{}%
+    {\EkdosisStart\add@apparatus}%
     \EkdosisOn#1}{%
     \EkdosisOff
   \end{linenumbers}%
-- 
cgit v1.2.3

