From 453f94204f99291fc0bacec256167294f571562d Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Tue, 1 Oct 2019 22:11:56 +0200
Subject: generate anchors to be referred to by notes

---
 ekdosis.dtx | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index fd1768e..0b941db 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1267,19 +1267,22 @@ local function note_totei(str)
 		 
 		 if left ~= "" and teitype ~= ""
 		 then
-		    return string.format("<%s type=\"%s\" target=\"#range(right(%s),left(%s))\">%s</%s>",
-					 cmd, teitype, right, left, arg, cmd)
+		    return string.format(
+		       "<%s type=\"%s\" target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>",
+					 cmd, teitype, right, left, arg, cmd, right)
 		 elseif left ~= "" and teitype == ""
 		 then
-		    return string.format("<%s target=\"#range(right(%s),left(%s))\">%s</%s>",
-					 cmd, right, left, arg, cmd)
+		    return string.format(
+		       "<%s target=\"#range(right(%s),left(%s))\">%s</%s><anchor xml:id=\"%s\"/>",
+					 cmd, right, left, arg, cmd, right)
 		 elseif left == "" and teitype ~= ""
 		 then
-		    return string.format("<%s type=\"%s\" target=\"#right(%s)\">%s</%s>",
-					 cmd, teitype, right, arg, cmd)		    
+		    return string.format(
+		       "<%s type=\"%s\" target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
+					 cmd, teitype, right, arg, cmd, right)		    
 		 else
-		    return string.format("<%s target=\"#right(%s)\">%s</%s>",
-					 cmd, right, arg, cmd)
+		    return string.format("<%s target=\"#right(%s)\">%s</%s><anchor xml:id=\"%s\"/>",
+					 cmd, right, arg, cmd, right)
 		 end
    end)
    return str
@@ -1419,6 +1422,13 @@ local function cmdtotei(str)
 						   cmdtotags[i].b..">", body)
       end)
    end
+   -- temporarily:
+   str = string.gsub(str, "\\(linelabel)%s?(%b{})",
+		     function(cmd, body)
+			body = string.sub(body, 2, -2)
+			body = cmdtotei(body)
+			return string.format("<anchor xml:id=\"%s\"/>", body)
+   end)
    str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})",
 		     function(cmd, opt, body)
 			body = string.sub(body, 2, -2)
-- 
cgit v1.2.3

