2022-04-25 15:49:13 +00:00
|
|
|
|
{{- $footnote_heading := printf "Footnotes" -}}
|
|
|
|
|
{{- if .Params.footnote_heading -}}
|
|
|
|
|
{{- $footnote_heading = .Params.footnote_heading -}}
|
|
|
|
|
{{- end -}}
|
2022-04-06 04:41:08 +00:00
|
|
|
|
|
2022-04-25 15:49:13 +00:00
|
|
|
|
<!--
|
|
|
|
|
Add heading to footnotes, remove unused class.
|
|
|
|
|
Requires Goldmark v1.4.12 or higher, since that version switched
|
2022-08-09 00:30:43 +00:00
|
|
|
|
endnotes from a <section> to a <div>. This switches them back to a section,
|
|
|
|
|
since doc-endnotes inherits a <section> role.
|
2022-04-25 15:49:13 +00:00
|
|
|
|
-->
|
|
|
|
|
{{- $referencesWithoutHeading := `(<div class="footnotes" role="doc-endnotes">
|
2022-05-30 22:49:31 +00:00
|
|
|
|
<hr />)` -}}
|
2022-06-06 04:17:18 +00:00
|
|
|
|
{{- $referencesWithHeading := printf `<hr />
|
|
|
|
|
<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-05-04 04:30:20 +00:00
|
|
|
|
{{- $endnotesClosingDiv := `</a></p>
|
|
|
|
|
</li>
|
|
|
|
|
</ol>
|
|
|
|
|
</div>` -}}
|
|
|
|
|
|
|
|
|
|
{{- $endnotesClosingSection := printf `</a></p>
|
|
|
|
|
</li>
|
|
|
|
|
</ol>
|
|
|
|
|
</section>` -}}
|
|
|
|
|
|
2022-06-07 04:42:32 +00:00
|
|
|
|
<!--
|
|
|
|
|
Sometimes I want multiple described terms for a set of descriptions
|
|
|
|
|
in a description list
|
|
|
|
|
-->
|
2023-11-05 00:04:07 +00:00
|
|
|
|
{{- $combinedTerm := `<dt([^>]*)?>(.*) OR (.*)</dt>` -}}
|
|
|
|
|
{{- $splitTerm := `<dt$1>$2</dt><dt>$3</dt>` -}}
|
2022-06-07 04:42:32 +00:00
|
|
|
|
|
2022-05-20 00:18:14 +00:00
|
|
|
|
<!--
|
|
|
|
|
Descriptive footnote link names, remove unused class, put
|
|
|
|
|
backlink id in <a> since <a> is focusable, remove unused class.
|
|
|
|
|
-->
|
|
|
|
|
{{- $badNoteRef := `<sup id="fnref([0-9\:]*)"><a( [^>]*)class="footnote-ref" role="doc-noteref">([0-9]*)</a>` -}}
|
2022-05-30 22:49:31 +00:00
|
|
|
|
{{- $goodNoteRef := `<sup><a${2}id="fnref${1}" role="doc-noteref">note ${3}</a>` -}}
|
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-25 15:49:13 +00:00
|
|
|
|
{{- $tocHeadingOutside := `<h2>Table of Contents</h2><nav(?:.*)>` -}}
|
2022-05-30 22:49:31 +00:00
|
|
|
|
{{- $tocHeadingInside := `<nav id="TableOfContents" role="doc-toc" aria-labelledby="toc-hd" tabindex="-1">
|
2022-05-20 00:18:14 +00:00
|
|
|
|
<h2 id="toc-hd">Table of Contents</h2>` -}}
|
2022-04-09 15:51:10 +00:00
|
|
|
|
|
2022-08-09 00:30:43 +00:00
|
|
|
|
<!--
|
|
|
|
|
Give footnote backlinks accessible names.
|
|
|
|
|
The backlinks should be located *outside* the footnote paragraphs.
|
|
|
|
|
-->
|
|
|
|
|
{{- $footnoteBacklinksBad := ` ?<a href="#fnref:([0-9]*)" class="footnote-backref"(.*role="doc-backlink"(?:[^>]*)?)>([^<]*)</a></p>` -}}
|
|
|
|
|
{{- $footnoteBacklinksGood := `</p><a href="#fnref:${1}" aria-labelledby="bl1-${1} bl2-${1}"${2}><span id="bl1-${1}">Back</span><span id="bl2-${1}" hidden=""> to reference ${1}</span></a>` -}}
|
2022-04-18 15:59:43 +00:00
|
|
|
|
|
2022-05-13 03:51:11 +00:00
|
|
|
|
<!--
|
|
|
|
|
If two backlinks exist, give them different names.
|
|
|
|
|
I currently don't have any triple backlinks; if I ever do, I'll implement this properly with a loop.
|
|
|
|
|
-->
|
2022-08-09 00:30:43 +00:00
|
|
|
|
{{- $repeatedFootnoteBacklinksBad := ` ?<a href="#fnref([0-9]):([0-9]*)"(.*role="doc-backlink"(?:[^>]*)?)>([^<]*)<a></p>` -}}
|
|
|
|
|
{{- $repeatedFootnoteBacklinksGood := `</p><a href="#fnref${1}:${2}" aria-labelledby="bl1-${2}-2 bl2-${2}-2"${3}><span id="bl1-${2}-2">Back</span><span id="bl2-${2}-2" hidden=""> to reference ${2}, instance 2</span></a>` -}}
|
2022-05-20 00:18:14 +00:00
|
|
|
|
|
|
|
|
|
<!--Make endnotes focusable by ATs. Necessary for VoiceOver compatibility.-->
|
|
|
|
|
{{- $endNotesNotFocusable := `<li id="fn:([0-9]*)">` -}}
|
|
|
|
|
{{- $endNotesFocusable := `<li id="fn:${1}" tabindex="-1">` -}}
|
|
|
|
|
|
2022-06-02 05:11:40 +00:00
|
|
|
|
|
|
|
|
|
<!--Since language-figure doesn't seem to work for some reason just use regex to replace it-->
|
2022-06-09 01:17:33 +00:00
|
|
|
|
{{- $extraLanguageFigure := `<pre><(code|samp) class="language-figure">` -}}
|
|
|
|
|
{{- $replacedLanguageFigure := `<pre tabindex="0"><${1} translate="no" itemprop="text">` -}}
|
2022-06-02 05:11:40 +00:00
|
|
|
|
|
2022-06-11 20:32:03 +00:00
|
|
|
|
{{- .Content | replaceRE $referencesWithoutHeading $referencesWithHeading | replaceRE $badNoteRef $goodNoteRef | replaceRE $endnotesClosingDiv $endnotesClosingSection | replaceRE $combinedTerm $splitTerm | replaceRE $tocHeadingOutside $tocHeadingInside | replaceRE $footnoteBacklinksBad $footnoteBacklinksGood | replaceRE $repeatedFootnoteBacklinksBad $repeatedFootnoteBacklinksGood | replaceRE $endNotesNotFocusable $endNotesFocusable | replaceRE $extraLanguageFigure $replacedLanguageFigure | replaceRE `\’` `’` | replaceRE `\ ` ` ` | replaceRE `\“` `“` | replaceRE `\”` `”` | replaceRE `\…` `…` | replaceRE `\—` `—` | replaceRE `\­` `­` | replaceRE `‘` `‘`| safeHTML -}}
|