blob: f988b30f6766184c1b3a2c88f0c048e2697bca5f (
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
|
<!-- KaTeX -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha256-tn6hZ2YGDv0w1/DaFL4MiUoXuAVclrtFZs13ch3TB9M=" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha256-1qhJwAgsSPVSSjlQVTewHS49eaoAbOz651dveUANVBI=" crossorigin="anonymous"></script>
<!-- mhchem extension -->
{{ if or (in .Params.katexExtensions "mhchem") (in .Site.Params.katexExtensions "mhchem") }}
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/mhchem.min.js" integrity="sha256-eI7Tty86eW+t5CeLj2o77+bKgW1jLziQASHI3lh+sn8=" crossorigin="anonymous"></script>
{{ end }}
<!-- copy-tex extension -->
{{ if or (in .Params.katexExtensions "copy-tex") (in .Site.Params.katexExtensions "copy-tex") }}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/copy-tex.min.css" integrity="sha256-v5/0E3/sOPYlVBnhQtCIPJxSCQiF10b4Du4SsnPZs+A=" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/copy-tex.min.js" integrity="sha256-KrIjcykCG8RDmGyDJ/bmE1f7aKVOXSM9IkAjcYwCIH0=" crossorigin="anonymous"></script>
{{ end }}
<!-- auto-render extension + tabIndex HACK (see below) -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha256-oEuQVLwO5Ii6subChtLbrY5gx7NDRU+UJJ9jvvau+FI=" crossorigin="anonymous" onload="renderMathInElement(document.body);addTabIndex()"></script>
<!--
HACK
Google Chrome will ignore "scroll" elements while navigating via keyboard
I could "fix" such behavior by using "tabindex=0"
But since KaTeX stuff here is being injected with JS, it seems I need to fight JS with JS
(what a BS...)
-->
<script>
'use strict';
function getAll(selector) {
return Array.prototype.slice.call(document.querySelectorAll(selector), 0)
};
function addTabIndex() {
const $katexBlocks = getAll('span.katex-display');
// Some a11y
const $katexLabel = {{ T "boxContainingExpression" }};
$katexBlocks.forEach(function ($el) {
$el.tabIndex = 0;
$el.setAttribute('aria-label', $katexLabel);
})
}
</script>
|