blob: bb664af5ad5d8d2662a89a142cda046729a8b84a (
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
|
<!-- KaTeX -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha512-SBL9R0mkYbWGuy/0DLHNxYHPScUMar9Y55t8vrnN42ZYfLZ4SnjXqCFfEhPTnj9pedAs5F+WZkzjq1qGS8+VGg==" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha512-2k+W+3OGhtd3whnGt33ek/oA1M/aqB6Mir+WIcCrSuIC2yD6iTX6IuPf5q1oEJGQT06jma5K6ca7Xqb4u7Urow==" crossorigin="anonymous"></script>
<!-- mchem extension -->
{{ if or (in .Params.katexExtensions "mchem") (in .Site.Params.katexExtensions "mchem") }}
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/mhchem.min.js" integrity="sha512-B4sSu3isYYpaurfStmXsh1wL71s8xKFZyNjCCuUHw8feCh9RlpG03x8+a3egFiZ1VuCoj6463IY18VnrDBbKuA==" 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.11.1/dist/contrib/copy-tex.css" integrity="sha512-gLOBccbZVR13Jvu/EZJAGz9C6P8CGD10sCGt/EdH5xHMKU3S9m43i6BX0ZqWIKeRo0JYXJiLi3Lv0gCAxFqz+Q==" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/copy-tex.min.js" integrity="sha512-DJT2Gf9zoglFWNuxgFcMZ3zi9Ra9GPDxpw9/8kyQ6cji+SOaLlV1A49Its53eLZlGfb4WjwRCptEUdNju6Wxgw==" crossorigin="anonymous"></script>
{{ end }}
<!-- auto-render extension + tabIndex HACK (see below) -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha512-GicGrbLBXJh2kbF+DYD+sCW5hPavoOfVAKSOE7+qgYCgVTcwe+/D4LXegS9JVTY72ovc5Ung4Fml+i1uD3uOyQ==" 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');
// While we are at it... Some a11y
const $katexLabel = {{ T "box_containing_expression" }};
$katexBlocks.forEach(function ($el) {
$el.tabIndex = 0;
$el.setAttribute('aria-label', $katexLabel);
})
}
</script>
|