-
Notifications
You must be signed in to change notification settings - Fork 0
/
katex-header.html
66 lines (56 loc) · 2.31 KB
/
katex-header.html
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css"
integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js"
integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script>
<script>
function renderKaTexDocs() {
let to_do = [];
for(let e of document.getElementsByTagName("code")) {
if(e.parentElement.tagName == "PRE" && e.classList.contains("language-math")) {
to_do.push(function() {
let x = document.createElement('p');
katex.render(e.innerText, x, { displayMode: true, throwOnError: false, trust: true });
e.parentNode.parentNode.replaceChild(x, e.parentNode);
});
} else if(e.parentElement.nodeType == 1 && e.innerHTML.indexOf('$') != -1) {
to_do.push(function() {
let x = document.createElement('span');
x.innerHTML = e.innerHTML;
renderMathInElement(x, {
displayMode: false, throwOnError: false, delimiters: [
{ left: "$", right: "$", display: false },
]
});
if(e.innerHTML != x.innerHTML) {
e.replaceWith(x);
}
});
}
}
for(let f of to_do) f();
}
</script>
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js"
integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" onload="renderKaTexDocs();"></script>
<style>
.katex-display>.katex {
text-align: left;
}
.katex .mspace {
margin-top: 0.3em;
}
</style>
<style>
.flex-container {
display: flex;
margin-bottom: 1em;
}
.flex-child {
flex: 1;
}
.flex-child:first-child {
margin-right: 20px;
}
</style>