Summary Files Commits Branches @commit @diff @stats
path: root / demo / awk-scripts
diff options
context:
space:
mode:
2 files changed, 13 insertions, 0 deletions
-rw-r--r--demo/awk-scripts/Blog-info.awk6
-rw-r--r--demo/awk-scripts/Heading-anchors.awk7
diff --git a/demo/awk-scripts/Blog-info.awk b/demo/awk-scripts/Blog-info.awk
new file mode 100644
index 0000000..89e044a
--- /dev/null
+++ b/demo/awk-scripts/Blog-info.awk
@@ -0,0 +1,6 @@
+# .*blog/.*/.*\.html
+# Adds an element with date created, date edited and estimated read time below h1
+
+/<h1/ {
+ $0 = $0 ORS "<div>Created: " created " | Last edited: " edited " | Read time: " (int(words / 180)+1) " min</div>"
+}
diff --git a/demo/awk-scripts/Heading-anchors.awk b/demo/awk-scripts/Heading-anchors.awk
new file mode 100644
index 0000000..7216c6d
--- /dev/null
+++ b/demo/awk-scripts/Heading-anchors.awk
@@ -0,0 +1,7 @@
+# .*\.html
+# Adds an HTML anchor after every header element (except h1), with an href to that header
+
+/<h[23456]/ {
+ match($0, /id="[^"]*"/)
+ $0 = $0 ORS "<a href=\"#" substr($0, RSTART + 4, RLENGTH - 5) "\">&sect;</a>"
+}