Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks
diff options
context:
space:
mode:
1 files changed, 16 insertions, 0 deletions
-rw-r--r--generate-hooks/create-header-anchors.awk16
diff --git a/generate-hooks/create-header-anchors.awk b/generate-hooks/create-header-anchors.awk
new file mode 100644
index 0000000..5381e81
--- /dev/null
+++ b/generate-hooks/create-header-anchors.awk
@@ -0,0 +1,16 @@
+#
+# == 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 href=\"#" id "\"><img src=\"/img/link-tabler.svg\" alt=\"🔗\"></a>")
+}
+
+{
+ print
+}