1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-15 01:42:10 +00:00
seirdy.one/layouts/partials/processed-content.html

29 lines
1.5 KiB
HTML
Raw Normal View History

2022-04-18 15:59:43 +00:00
{{ $footnote_heading := printf "Footnotes" -}}
{{ if .Params.footnote_heading -}}
2022-04-18 15:59:43 +00:00
{{ $footnote_heading = .Params.footnote_heading -}}
{{end}}
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">
<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) -}}
<!--Remove deprecated DPUB-ARIA role and unused classes-->
{{ $endnote := `(role="doc-endnote"|class="footnote-(back)?ref")` }}
{{ $noEndnote := printf "" }}
2022-04-07 00:49:25 +00:00
<!--Add tabindex to all <pre> elements, inc. those that aren't generated by Goldmark-->
2022-04-07 00:49:25 +00:00
{{ $preWithoutTabIndex := `<pre>` }}
{{ $preWithTabIndex := `<pre tabindex="0">` }}
2022-04-07 00:49:25 +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(?:.*)>` }}
{{ $tocHeadingInside := `<nav id=TableOfContents role="doc-toc"><h2 id="toc-hd">Table of Contents</h2>` }}
2022-04-18 15:59:43 +00:00
<!--Give footnote backlinks accessible names-->
{{ $footnoteBacklinksBad := `<a href="#fnref:([0-9]*)"(.*role="doc-backlink"(?:.*)?)>` }}
{{ $footnoteBacklinksGood := `<a href="#fnref:${1}" title="back to reference $1" aria-label="back to reference $1"${2}>` }}
{{ .Content | replaceRE $referencesWithoutHeading $referencesWithHeading | replaceRE $endnote $noEndnote | replaceRE $preWithoutTabIndex $preWithTabIndex | replaceRE $tocHeadingOutside $tocHeadingInside | replaceRE $footnoteBacklinksBad $footnoteBacklinksGood | safeHTML -}}