summaryrefslogtreecommitdiffstats
path: root/katex-header.html
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-06-26 17:20:22 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-06-27 13:58:43 -0400
commite466113d70e9786259b3516b5951771b0706e5d8 (patch)
tree9abce5a134d5f437d8f1b6f70bba9669f191b82e /katex-header.html
parentb4e301a2a4e6e00a1b521cae8e1a015ab8fc2b54 (diff)
downloadacap-e466113d70e9786259b3516b5951771b0706e5d8.tar.xz
docs: Integrate KaTeX and add some formulas
Diffstat (limited to 'katex-header.html')
-rw-r--r--katex-header.html22
1 files changed, 22 insertions, 0 deletions
diff --git a/katex-header.html b/katex-header.html
new file mode 100644
index 0000000..4e73ba1
--- /dev/null
+++ b/katex-header.html
@@ -0,0 +1,22 @@
+<!-- Credit: https://stackoverflow.com/a/54573800 -->
+<!-- Credit: https://github.com/m-ou-se/rust-horrible-katex-hack/blob/master/src/lib.rs -->
+
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous" />
+<script defer src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
+<script>
+ document.addEventListener("DOMContentLoaded", () => {
+ let codes = [...document.getElementsByTagName("code")];
+ for (let code of codes) {
+ if (code.classList.contains("language-math")) {
+ let p = document.createElement("p");
+ katex.render(code.textContent, p, { displayMode: true });
+ let pre = code.parentNode;
+ pre.parentNode.replaceChild(p, pre);
+ } else if (/^\$.*\$$/.test(code.textContent)) {
+ let span = document.createElement("span");
+ katex.render(code.textContent.slice(1, -1), span);
+ code.parentNode.replaceChild(span, code);
+ }
+ }
+ });
+</script>