Summary Files Commits Branches @commit @diff @stats
path: root / awk-edits / Heading-anchors.awk
blob: ee69043f2a907a125d13a92908b2405a6518c99a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# .*html
#
# == 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]/ {
	match($0, /<h./)
	headerLevel = (substr($0, RSTART + 2, 1) == 2) ? "" : "-small"
	match($0, /id="[^"]*"/)
	$0 = "<div class=\"gap" headerLevel "\"></div>" ORS $0 ORS "<a class=\"h-anchor\" href=\"#" substr($0, RSTART + 4, RLENGTH - 5) "\" aria-hidden=\"true\">&#x00A7;</a>"
}