2022-06-22 21:18:32 -07:00
|
|
|
<!--
|
|
|
|
Intended properties of this render-hook:
|
|
|
|
|
|
|
|
1. Headings are focusable, but not from the keyboard. This allows VoiceOver to navigate to a heading from the TOC.
|
|
|
|
2. <h2> elements are followed by a section permalink, which is useful for sharing a subset of an article.
|
|
|
|
3. The page looks as similar as possible to graphical-browsers, textual browsers (e.g. Lynx), and assistive technologies.
|
|
|
|
4. Reading-mode implementations preserve headings without getting confused by the section permalinks.
|
|
|
|
5. Machine-translation works as intended with or without assistive technologies.
|
|
|
|
6. All of this applies with or without CSS.
|
|
|
|
|
|
|
|
To achieve all these properties, I had to break the first rule of ARIA and misuse <aside>.
|
|
|
|
I'm a markup criminal now.
|
|
|
|
-->
|
2022-07-13 17:33:42 -07:00
|
|
|
{{- $id := .Anchor | safeURL -}}
|
|
|
|
{{- if eq .Level 1 -}}
|
|
|
|
{{- $id = "h1" -}}
|
|
|
|
{{- end -}}
|
|
|
|
<h{{ .Level }} id="{{ $id }}" tabindex="-1">{{ .Text | safeHTML -}}</h{{ .Level }}>
|
2022-07-11 15:19:50 -07:00
|
|
|
{{- if and (eq .Level 2) (.Page.Section) (ne .Page.Section "notes") -}}
|
2022-06-22 21:18:32 -07:00
|
|
|
<!--crimes-->
|
|
|
|
<aside role="none"><a
|
2022-07-13 22:01:13 -07:00
|
|
|
href="#{{ .Anchor | safeURL }}"
|
2022-05-19 17:18:14 -07:00
|
|
|
aria-labelledby="{{ .Anchor | safeURL }}-prefix {{ .Anchor | safeURL }}">
|
2022-05-19 13:21:10 -07:00
|
|
|
<span id="{{ .Anchor | safeURL }}-prefix">Permalink to section</span>
|
2022-06-22 21:18:32 -07:00
|
|
|
</a></aside>
|
2022-04-25 17:29:34 -07:00
|
|
|
{{- end }}
|