From 603a4562819fca15dd66831a10b1fd7344d2cd83 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Wed, 17 Aug 2016 19:10:53 +0200
Subject: compute linelabels and linerefs with md5sum

---
 ekdosis.dtx | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 50 insertions(+), 9 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 5430f87..5248f96 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -40,7 +40,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see
 <http://www.gnu.org/licenses/>.
 --]]
-
+	  
 function closestream()
       os.remove(tex.jobname..".ekd")
       os.rename(tex.jobname.."_tmp.ekd", tex.jobname..".ekd")
@@ -90,6 +90,35 @@ function testapparatus()
    file:close()
 end
 
+function getlab()
+   return "\\getrefnumber{ekdl:\\theedk@lab}"
+end
+
+--[[
+local linecount = 0
+
+count_lines = function(head)
+   while head do
+      if head.id == 0 then
+	 linecount = linecount + 1
+      end
+      head = head.next
+   end
+   return true
+end
+
+count_lines = function(head)
+   for line in node.traverse_id(0, head) do
+      linecount = linecount + 1
+   end
+   return head
+end
+
+function getline()
+  return linecount
+end
+--]]
+
 %</lua>
 %<*internal>
 \fi
@@ -181,12 +210,15 @@ Running "make install" installs the files in the local TeX tree.
 \usepackage[numbered]{hypdoc}
 \usepackage{\jobname}
 \usepackage{fontspec,luatextra}
+\usepackage{authblk}
 \newcommand{\package}[1]{\textsf{#1}\index{#1=#1 (package)}}
 \EnableCrossrefs
 \CodelineIndex
 \RecordChanges
 \begin{document}
   \DocInput{\jobname.dtx}
+  \PrintChanges
+  \PrintIndex
 \end{document}
 %</driver>
 % \fi
@@ -212,11 +244,13 @@ Running "make install" installs the files in the local TeX tree.
 % \GetFileInfo{\jobname.dtx}
 % \DoNotIndex{\newcommand,\newenvironment}
 %
-%\title{\textsf{ekdosis} --- Typesetting of TEI xml compliant critical editions\thanks{This file
-%   describes version \fileversion, last revised \filedate.}
-%}
-%\author{Robert Alessi}
-%\date{\fileversion\ released \filedate}
+% \title{\textsf{ekdosis} --- Typesetting of TEI xml compliant
+% critical editions\thanks{This file describes version \fileversion,
+% last revised \filedate.}  }
+%  
+% \author{Robert Alessi}
+% \affil{CNRS UMR 8167 (Paris, France)\footnote{\url{robert.alessi@cnrs.fr}}}
+% \date{\fileversion\ released \filedate}
 %
 %\maketitle
 %
@@ -243,9 +277,6 @@ Running "make install" installs the files in the local TeX tree.
 % mandatory and optional arguments are, and so forth.
 %
 % \StopEventually{}
-% \PrintChanges
-% \PrintIndex
-%
 %
 % \section{Implementation}
 %
@@ -275,6 +306,7 @@ Running "make install" installs the files in the local TeX tree.
 \RequirePackage{luacode}
 \RequirePackage{xparse}
 \RequirePackage{etoolbox}
+\RequirePackage[addpageno]{lineno}
 \RequirePackage{float}
 \newfloat{apparat}{b}{lap}
 \RequirePackage{afterpage}
@@ -297,6 +329,10 @@ Running "make install" installs the files in the local TeX tree.
     \luadirect{appin(\luastringN{#1}, "no")}%
     \luadirect{appin(\luastring{</\getpagerefnumber{ekd:\theekd@lab}>}, "yes")}%
     \stepcounter{ekd@lab}}{}}
+\NewDocumentCommand{\mdv}{m}{%
+  \luadirect{tex.sprint(md5.sumhexa(\luastringN{#1}))}}
+\NewDocumentCommand{\obappend}{+m}{%
+  \linelabel{\mdv{#1}}\append{\getrefnumber{\mdv{#1}}~#1}}
 \NewDocumentCommand{\myappend}{+m}{%
   \ifbool{ekdstate}{%
     \label{\getlab}%
@@ -330,6 +366,11 @@ Running "make install" installs the files in the local TeX tree.
 \newenvironment{ekdosis}{%
 \ifbool{ekdstarted}{}{\EkdosisStart\global\setbool{ekdstarted}{true}}
 \EkdosisOn}{\EkdosisOff}
+\newenvironment{countlines}%
+{\directlua{luatexbase.add_to_callback("post_linebreak_filter",
+    count_lines, "count_lines")}}%
+{\par
+\directlua{luatexbase.remove_from_callback("post_linebreak_filter", "count_lines")}}
 %    \end{macrocode}
 % That is it. Say goodbye before leaving.
 %    \begin{macrocode}
-- 
cgit v1.2.3

