mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-30 15:22:09 +00:00
eb8ca07b9f
- Goldmark 1.4.12 switches footnotes from a <section> to a <div>; update regexes and stylesheet to account for this. - Goldmark 1.4.12 allows multiple footnotes with the same reference; use that. - Clean up templates for unminified output. Also delete an unused class. - Switch to unminified output by default.
28 lines
1.4 KiB
HTML
28 lines
1.4 KiB
HTML
{{- $footnote_heading := printf "Footnotes" -}}
|
|
{{- if .Params.footnote_heading -}}
|
|
{{- $footnote_heading = .Params.footnote_heading -}}
|
|
{{- end -}}
|
|
|
|
<!--
|
|
Add heading to footnotes, remove unused class.
|
|
Requires Goldmark v1.4.12 or higher, since that version switched
|
|
endnotes from a <section> to a <div>.
|
|
-->
|
|
{{- $referencesWithoutHeading := `(<div class="footnotes" role="doc-endnotes">
|
|
<hr>)` -}}
|
|
{{- $referencesWithHeading := printf `<div role="doc-endnotes" aria-labelledby="note-hd">
|
|
<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 "" -}}
|
|
|
|
<!--Move the Table of Contents heading *inside* the <nav> element-->
|
|
{{- $tocHeadingOutside := `<h2>Table of Contents</h2><nav(?:.*)>` -}}
|
|
{{- $tocHeadingInside := `<nav id=TableOfContents role="doc-toc"><h2 id="toc-hd">Table of Contents</h2>` -}}
|
|
|
|
<!--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 $tocHeadingOutside $tocHeadingInside | replaceRE $footnoteBacklinksBad $footnoteBacklinksGood | safeHTML -}}
|