Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks / create-header-anchors.awk
blob: a07c736edc53f85e4145e0297efd767ff391eba0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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=\"🔗\" loading=\"lazy\"></a>")
}

{
	print
}