Summary Files Commits Branches @commit @diff @stats
path: root / awk-edits / Heading-anchors.awk
diff options
context:
space:
mode:
Commit0187e255a811bebb0dad3624f2c6d78b829d15c5 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-01-17 16:15:28 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-01-17 16:15:28 +0200
Files68efd3520e72c8c8c553fdda7b9391d9ec4e9feb /awk-edits/Heading-anchors.awk
syndamia.com-0187e255a811bebb0dad3624f2c6d78b829d15c5.tar
syndamia.com-0187e255a811bebb0dad3624f2c6d78b829d15c5.tar.gz
syndamia.com-0187e255a811bebb0dad3624f2c6d78b829d15c5.zip
Parentda000c477625bb533688df84bd95ba3a3aff3246 (diff)
[awk] Reworked generation to happen via a combined script, updated scripts and added info in scripts readme
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>")
+}