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
Rohan Kumar 7bd796a44c
Floating block examples, Tkhtml, semantics, other
- Change a quote of a code snippet to a code snippet with a citation
- Mention tkhtml
- Mention pandoc and printfriendly as exmples of moving figure elements
  like floating blocks.
- Make TPGi a publisher, not an author.
- Use brackets to clarify a reference in a quotation.
- Add personal example of why it's important to test both low- and
  high-end displays.
2022-05-08 21:08:08 -07:00

44 lines
2.1 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 `<section role="doc-endnotes" aria-labelledby="note-hd">
<h2 id="note-hd">%s</h2>` ($footnote_heading) -}}
{{- $endnotesClosingDiv := `</a></p>
</li>
</ol>
</div>` -}}
{{- $endnotesClosingSection := printf `</a></p>
</li>
</ol>
</section>` -}}
{{- $badNoteRef := ` role="doc-noteref">([0-9]*)</a>` -}}
{{- $goodNoteRef := ` role="doc-noteref">note&nbsp;${1}</a>` -}}
<!--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}>` -}}
{{- $repeatedFootnoteBacklinksBad := `<a href="#fnref([0-9]):([0-9]*)"(.*role="doc-backlink"(?:.*)?)>` -}}
{{- $repeatedFootnoteBacklinksGood := `<a href="#fnref${1}:${2}" title="back to reference ${2}, repeated instance ${1}" aria-label="back to reference ${2}, repeated instance ${1}"${3}>` -}}
{{- .Content | replaceRE $referencesWithoutHeading $referencesWithHeading | replaceRE $badNoteRef $goodNoteRef | replaceRE $endnotesClosingDiv $endnotesClosingSection | replaceRE $endnote $noEndnote | replaceRE $tocHeadingOutside $tocHeadingInside | replaceRE $footnoteBacklinksBad $footnoteBacklinksGood | replaceRE $repeatedFootnoteBacklinksBad $repeatedFootnoteBacklinksGood | safeHTML -}}