Welcome to mirror list, hosted at ThFree Co, Russian Federation.

processed-content.html « partials « layouts - gitlab.com/rmaguiar/hugo-theme-color-your-world.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fbbe353be040b14aed4b2781131f38ddb4dbce09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!--
  HACK
  For some reason, Chrome will ignore some elements when using TAB
  (while Firefox will not). Since Chrome is used by the majority,
  I feel like I need to "fix" this.
  
  For now, I'll be using "tabindex=0" (even if it makes Firefox
  complain about accessibility).
  
  I'm also taking this as an opportunity to fix other minor details
  like i18n and responsiveness.
  
  Hopefully, most of the mess below can be removed in the future
  as Hugo evolves and more render hooks are implemented. (It used
  to also add anchor links to headings before render hooks were
  implemented.)
-->

<!-- i18n -->
{{ $references    := (printf "${1}<h2>%s</h2>" (T "references")) }}
{{ $seeFootnotes  := (printf "${1} title=\"%s\"" (T "see_footnotes")) }}
{{ $returnToText  := (printf "${1} title=\"%s\"" (T "return_to_text")) }}

<!-- More i18n and also a11y, kind of -->
{{ $highlightCodeBlockLabel := (printf "${1} aria-label=\"%s\" tabindex=0${2}" (T "box_containing_code")) }}
{{ $indentedCodeBlockLabel  := (printf "${1} aria-label=\"%s\" tabindex=0>${2}" (T "box_containing_code")) }}

<!-- Wrap tables to make use of overflow-x property (plus the tabindex thing) -->
{{ $improvedTable := printf "<section class=scroll tabindex=0> ${1} </section>" }}

<!-- Replace the footnote return links with a text label -->
{{ $footnoteReturnLink := (printf "${1}%s${2}" (T "return")) }}

<!-- Replace the inline "padding:0" present if using the default Chroma -->
{{ $highlightPadding := (printf "${1}padding: var(--il-pad)") }}

<!-- OR replace the footnote return links with a SVG icon -->
{{ if .Site.Params.Style.hasIconAsFootnoteReturnLink }}
  {{ $footnoteReturnLink = (printf "${1}<svg transform=\"rotate(180) translate(0 -1)\" aria-hidden=\"true\" ><use xlink:href=\"#caret-down\"/></svg>${2}") }}
{{ end }}

<!--
  This is doing 4 things right now (or is it):
  
  * Adding "tabindex=0" to native table and code fences;
  * Making tables scrollable;
  * Localizing some text;
  * Adding a "h2" to footnotes;
  * Changing the default inline style for default Chroma.
-->

{{ .Content | replaceRE "(<table>(?:.|\n)+?</table>)" $improvedTable | replaceRE "(<div class=\"highlight\"><(?:pre|div) class=\"chroma\")(>)" $highlightCodeBlockLabel | replaceRE "(<pre)>(<code>)" $indentedCodeBlockLabel | replaceRE "(class=\"footnote-ref\")" $seeFootnotes | replaceRE "(class=\"footnote-backref\")" $returnToText | replaceRE "(<section class=\"footnotes\" role=\"doc-endnotes\">)" $references | replaceRE "(<a (?:.*) class=\"footnote-backref\" (?:.*)>)(?:.*)(</a>)" $footnoteReturnLink | replaceRE "(?:(<div class=\"highlight\">(?:.|\n)+?<table (?:.*?))(?:padding:0))" $highlightPadding | safeHTML }}