From: Paul Hänsch <paul@plutz.net>
Date: Sun, 26 Jun 2022 17:52:18 +0000 (+0200)
Subject: recognize and omit anchor links when building toc
X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=b9be49d6871e7300adb0ecc055abb4de25cd6252;p=shellwiki

recognize and omit anchor links when building toc
---

diff --git a/macros/toc b/macros/toc
index 308fced..f3a6358 100755
--- a/macros/toc
+++ b/macros/toc
@@ -14,6 +14,6 @@ fi
 
 md |sed -nE '
   1i<ul class="macro toc">
-  s;<(h[1-6]) id="([^"]*)">([^<]+)</h[1-6]>;<li class="toc \1"><a href="#\2">\3</a></li>;p
+  s;^<(h[1-6]) id="([^"]*)">(([^<]|<[^aA]|<[aA][^ ])+)(<a class="anchor" href="[^>]*"></a>)?</h[1-6]>$;<li class="toc \1"><a href="#\2">\3</a></li>;p
   $i</ul>
 '