mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-27 14:12:09 +00:00
84cde2e97f
Create a for <figcaption> and a render hook for code snippets inside figures, replacing some ugly and complex inline HTML in my markdown sources. The only visible change is slightly worse HTML alignment and programming language indicators (with microdata). This removed the need to use one of the regex replacements in the processed_content.html shortcode, and increased the minimum required Hugo version to 0.93.
24 lines
1.3 KiB
HTML
24 lines
1.3 KiB
HTML
{{ $footnote_heading := printf "Footnotes" -}}
|
|
{{ if .Params.footnote_heading -}}
|
|
{{ $footnote_heading = .Params.footnote_heading -}}
|
|
{{end}}
|
|
|
|
<!--Add heading to footnotes, remove unused class-->
|
|
{{ $referencesWithoutHeading := `(<section class="footnotes" role="doc-endnotes">
|
|
<hr>)` -}}
|
|
{{ $referencesWithHeading := printf `<section 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 -}}
|