From 0b18082101e3e5ded71bd558a7096afd4d9caaa3 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Tue, 20 Apr 2021 20:29:45 +0200
Subject: print line numbers of nested \app (1/2); started working on headers
 and footers

---
 ekdosis.dtx | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index d867f27..a1bbe10 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -8200,6 +8200,21 @@ Sample text with a \textcolor{red}{word} in red.
       {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}}
       =
       0
+    %%%begin
+    \ifnum%
+    \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}}
+    =
+    0
+    \ifekd@isinlem
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd@postrefnum}% issue the no    
+    \fi
+    \else
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd@postrefnum}% issue the no    
+    \fi
+    %%%end
       \else
       \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
         \unexpanded\expandafter{\ekd@postrefnum}% issue the no
@@ -8214,6 +8229,21 @@ Sample text with a \textcolor{red}{word} in red.
     {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}}
     =
     0
+    %%%begin
+    \ifnum%
+    \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}}
+    =
+    0
+    \ifekd@isinlem
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd@postrefnum}% issue the no    
+    \fi
+    \else
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd@postrefnum}% issue the no    
+    \fi
+    %%%end
     \else
     \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
       \unexpanded\expandafter{\ekd@postrefnum}% issue the no
@@ -8972,6 +9002,19 @@ Sample text with a \textcolor{red}{word} in red.
   }
 %    \end{macrocode}
 % \end{environment}
+% \paragraph{Headers and Footers}
+%    \begin{macrocode}
+\NewDocumentCommand{\ekd@storemark}{m}{%
+  \stepcounter{ekd@lab}%
+  \zlabel{ekd:\theekd@lab}%
+  \luadirect{ekdosis.storehfmark(
+    \luastring{\zref@extract{ekd:\theekd@lab}{abspage}},
+    \luastringN{#1})}%
+}
+\NewDocumentCommand{\ekdmark}{}{%
+  \luadirect{tex.sprint(ekdosis.gethfmark(\luastring{\thepage}))}%
+}
+%    \end{macrocode}
 % \paragraph{Divisions of the Body}
 % \pkg{ekdosis} can convert \cs{book}, \cs{part}, \cs{chapter},
 % \cs{section}, \cs{subsec{\allowbreak}tion} and \cs{subsubsection}
@@ -9008,6 +9051,7 @@ Sample text with a \textcolor{red}{word} in red.
   code head = \def\head@value{#1},
   code barehead = \def\barehead@value{#1},
   store depth = \depth@value,
+  code mark = \ekd@storemark{#1},
   choice toc = {book = \def\toc@value{book},
                 part = \def\toc@value{part},
                 chapter = \def\toc@value{chapter},
@@ -10220,6 +10264,24 @@ local function self_close_tags(str)
    return str
 end
 
+--headers and footers
+local hfmarks = {}
+
+function ekdosis.storehfmark(page, mk)
+   table.insert(hfmarks, {a = page, mark = mk})
+   return true
+end
+
+function ekdosis.gethfmark(page)
+   local indexpage = get_a_index(page, hfmarks)
+   if hfmarks[indexpage] ~= nil
+   then
+      return hfmarks[indexpage].mark
+   else
+      return "nil"
+   end
+end
+
 local divdepth = {
    book = 1,
    part = 2,
-- 
cgit v1.2.3

