]> git.plutz.net Git - shellwiki/commitdiff
recognize and omit anchor links when building toc
authorPaul Hänsch <paul@plutz.net>
Sun, 26 Jun 2022 17:52:18 +0000 (19:52 +0200)
committerPaul Hänsch <paul@plutz.net>
Sun, 26 Jun 2022 17:52:18 +0000 (19:52 +0200)
macros/toc

index 308fceda9cab6ea6b52c8004cdfe603bdcaf366a..f3a6358fdc40c754e822105736c92da6688e27a1 100755 (executable)
@@ -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>
 '