migrate katex ( js portion ) to js bundle
This commit is contained in:
parent
fbafe4f671
commit
bf236e029e
10 changed files with 32 additions and 20 deletions
|
@ -17,3 +17,7 @@ if (process.env.FEATURE_FLOWCHART) {
|
|||
if (process.env.FEATURE_SYNTAXHIGHLIGHT) {
|
||||
import('./syntaxhighlight');
|
||||
}
|
||||
|
||||
if (process.env.FEATURE_MATH) {
|
||||
import('./math');
|
||||
}
|
||||
|
|
3
assets/scripts/features/math/index.js
Normal file
3
assets/scripts/features/math/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
if (process.env.FEATURE_MATH_KATEX) {
|
||||
import('./katex');
|
||||
}
|
21
assets/scripts/features/math/katex.js
Normal file
21
assets/scripts/features/math/katex.js
Normal 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 || {}),
|
||||
}
|
||||
);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue