migrate katex ( js portion ) to js bundle

This commit is contained in:
Aaron Qian 2022-11-11 15:14:56 -08:00 committed by Aaron Qian
parent fbafe4f671
commit bf236e029e
No known key found for this signature in database
GPG key ID: BF1A987C395B5B0E
10 changed files with 32 additions and 20 deletions

View file

@ -17,3 +17,7 @@ if (process.env.FEATURE_FLOWCHART) {
if (process.env.FEATURE_SYNTAXHIGHLIGHT) {
import('./syntaxhighlight');
}
if (process.env.FEATURE_MATH) {
import('./math');
}

View file

@ -0,0 +1,3 @@
if (process.env.FEATURE_MATH_KATEX) {
import('./katex');
}

View file

@ -0,0 +1,21 @@
import renderMathInElement from 'katex/contrib/auto-render';
import * as params from '@params';
const defaultOptions = {
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "\\[", right: "\\]", display: true},
{left: "$", right: "$", display: false},
{left: "\\(", right: "\\)", display: false}
]
}
window.addEventListener('DOMContentLoaded', () => {
renderMathInElement(
document.body,
{
...defaultOptions,
...(params.math?.katex || {}),
}
);
});