From b87f8ac606363d54619660745fab3f4cc180befe Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Sun, 8 Sep 2019 21:00:54 +0200
Subject: discard the line number if it is the same as the one of the previous
 unit

---
 ekdosis.dtx | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 8419858..ef3fd93 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -531,7 +531,21 @@ idno={}, msName={}, origDate={}][3]{%
       \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}
       =
       \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}
+      %
+      \ifsubsq@unit%
+      %
+      \ifnum%
+      \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}
+      =
+      \getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}
+      \else
       \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}%
+      \fi
+      %
+      \else
+      \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}%
+      \fi
+      %
       \else
       \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}--%
       \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}%
@@ -1418,10 +1432,12 @@ end
 local lnlabs = {}
 local lnlab_salt = 0
 local current_lnlab = nil
+local prev_lnlab = nil
 local current_lemma = nil
 local salt = 0
 
 function ekdosis.dolnlab(str)
+   prev_lnlab = current_lnlab
    current_lemma = str
    i = md5.sumhexa(str)
    if not mdvisintable(lnlabs, i) then
@@ -1431,14 +1447,18 @@ function ekdosis.dolnlab(str)
       table.insert(lnlabs, i)
       salt = salt + 1
    end
-      current_lnlab = i
-      return true
+   current_lnlab = i
+   return true
 end
 
 function ekdosis.getlnlab()
    return current_lnlab
 end
 
+function ekdosis.getprevlnlab()
+   return prev_lnlab
+end
+
 function ekdosis.mdvappend(str)
    return [[\linelabel{]] .. current_lnlab .. [[-b}\wordboundary{}]]
       ..
-- 
cgit v1.2.3

