2022-04-18 15:59:43 +00:00
|
|
|
{{ $footnote_heading := printf "Footnotes" -}}
|
2021-01-18 01:18:02 +00:00
|
|
|
{{ if .Params.footnote_heading -}}
|
2022-04-18 15:59:43 +00:00
|
|
|
{{ $footnote_heading = .Params.footnote_heading -}}
|
|
|
|
{{end}}
|
2022-04-06 04:41:08 +00:00
|
|
|
|
2022-04-14 01:21:39 +00:00
|
|
|
<!--Add heading to footnotes, remove unused class-->
|
2022-04-18 15:59:43 +00:00
|
|
|
{{ $referencesWithoutHeading := `(<section class="footnotes" role="doc-endnotes">
|
2021-01-18 03:42:07 +00:00
|
|
|
<hr>)` -}}
|
2022-04-07 00:49:25 +00:00
|
|
|
{{ $referencesWithHeading := printf `<section role="doc-endnotes" aria-labelledby="note-hd">
|
2022-04-18 15:59:43 +00:00
|
|
|
<h2 id="note-hd">%s</h2>` ($footnote_heading) -}}
|
2022-04-06 04:41:08 +00:00
|
|
|
|
2022-04-09 15:54:58 +00:00
|
|
|
<!--Remove deprecated DPUB-ARIA role and unused classes-->
|
2022-04-09 15:59:12 +00:00
|
|
|
{{ $endnote := `(role="doc-endnote"|class="footnote-(back)?ref")` }}
|
2022-04-06 04:41:08 +00:00
|
|
|
{{ $noEndnote := printf "" }}
|
2022-04-07 00:49:25 +00:00
|
|
|
|
2022-04-09 15:51:10 +00:00
|
|
|
<!--Move the Table of Contents heading *inside* the <nav> element-->
|
2022-04-18 15:59:43 +00:00
|
|
|
{{ $tocHeadingOutside := `<h2>Table of Contents</h2><nav(?:.*)>` }}
|
2022-04-18 08:29:05 +00:00
|
|
|
{{ $tocHeadingInside := `<nav id=TableOfContents role="doc-toc"><h2 id="toc-hd">Table of Contents</h2>` }}
|
2022-04-09 15:51:10 +00:00
|
|
|
|
2022-04-18 15:59:43 +00:00
|
|
|
<!--Give footnote backlinks accessible names-->
|
|
|
|
{{ $footnoteBacklinksBad := `<a href="#fnref:([0-9]*)"(.*role="doc-backlink"(?:.*)?)>` }}
|
2022-04-19 04:15:29 +00:00
|
|
|
{{ $footnoteBacklinksGood := `<a href="#fnref:${1}" title="back to reference ${1}" aria-label="back to reference ${1}"${2}>` }}
|
2022-04-18 15:59:43 +00:00
|
|
|
|
2022-04-19 04:15:29 +00:00
|
|
|
{{ .Content | replaceRE $referencesWithoutHeading $referencesWithHeading | replaceRE $endnote $noEndnote | replaceRE $tocHeadingOutside $tocHeadingInside | replaceRE $footnoteBacklinksBad $footnoteBacklinksGood | safeHTML -}}
|