Summary Files Commits Branches @commit @diff @stats
path: root / awk-edits / Heading-anchors.awk
diff options
context:
space:
mode:
1 files changed, 12 insertions, 0 deletions
-rw-r--r--awk-edits/Heading-anchors.awk12
diff --git a/awk-edits/Heading-anchors.awk b/awk-edits/Heading-anchors.awk
new file mode 100644
index 0000000..e4367c7
--- /dev/null
+++ b/awk-edits/Heading-anchors.awk
@@ -0,0 +1,12 @@
+#
+# == About ==
+#
+# ssg generates an id for every heading. That's why after every heading there
+# can be a hyperlink to itself. However, because of the current styling, such a
+# hyperlink is required (except for h1).
+
+/[ \t]*<h[23456]/ {
+ id = substr($0, index($0, "id=\"") + 4)
+ id = substr(id, 0, index(id, "\"") - 1)
+ gsub(/$/, ORS "<a class=\"h-anchor\" href=\"#" id "\"><img src=\"/img/link-tabler.svg\" alt=\"🔗\" loading=\"lazy\"></a>")
+}