Skip to content

Commit

Permalink
Test KaTeX: math is by element class; fix js links
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Oct 26, 2023
1 parent c1c2379 commit c30b307
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8"
crossorigin="anonymous"></script>
<script>document.addEventListener("DOMContentLoaded", function () {
var mathElements = document.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}}});
</script>

<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
</head>

<body>
Expand Down

0 comments on commit c30b307

Please sign in to comment.