Skip to content

Commit e4a3480

Browse files
committed
replace math rendering from katex to mathjax for extended support
1 parent 0f31961 commit e4a3480

File tree

3 files changed

+41
-33
lines changed

3 files changed

+41
-33
lines changed

layouts/partials/math.html

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css"
2-
integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous">
3-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"
4-
integrity="sha384-XjKyOOlGwcjNTAIQHIpgOno0Hl1YQqzUOEleOLALmuqehneUG+vnGctmUb0ZY0l8"
5-
crossorigin="anonymous"></script>
6-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js"
7-
integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05"
8-
crossorigin="anonymous"></script>
9-
<script defer src="/js/katex-macros.js"></script>
10-
111
<script>
12-
document.addEventListener("DOMContentLoaded", function () {
13-
renderMathInElement(document.body, {
14-
delimiters: [
15-
{ left: '\\[', right: '\\]', display: true }, // block
16-
{ left: '$$', right: '$$', display: true }, // block
17-
{ left: '\\(', right: '\\)', display: false }, // inline
18-
{ left: '$', right: '$', display: false }, // inline
19-
],
20-
throwOnError: false,
21-
macros: window.katexMacros
22-
});
23-
});
24-
</script>
2+
MathJax = {
3+
tex: {
4+
inlineMath: [['$', '$'], ['\\(', '\\)']],
5+
displayMath: [['$$', '$$'], ['\\[', '\\]']],
6+
tags: 'ams',
7+
packages: {'[+]': ['base', 'ams', 'color']}
8+
},
9+
options: {
10+
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
11+
ignoreHtmlClass: '.*|',
12+
processHtmlClass: '.*|'
13+
},
14+
loader: {
15+
load: ['[tex]/ams', '[tex]/color']
16+
},
17+
startup: {
18+
typeset: true
19+
}
20+
};
21+
</script>
22+
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

static/js/katex-macros.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

static/js/mathjax-macros.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
MathJax = {
2+
tex: {
3+
inlineMath: [['\\(', '\\)'], ['$', '$']],
4+
displayMath: [['\\[', '\\]'], ['$$', '$$']],
5+
macros: {
6+
// Define your custom macros here
7+
"\\RR": "\\mathbb{R}",
8+
"\\CC": "\\mathbb{C}",
9+
'\\NN': '\\mathbb{N}',
10+
'\\QQ': '\\mathbb{Q}',
11+
'\\PP': '\\mathbb{P}',
12+
'\\EE': '\\mathbb{E}',
13+
'\\ZZ': '\\mathbb{Z}',
14+
// ... other macros
15+
},
16+
tags: 'ams',
17+
packages: {'[+]': ['ams', 'color']}
18+
},
19+
// ... rest of config
20+
};

0 commit comments

Comments
 (0)