Files
FixIt/assets/js/lib/mathjax.js
T
Cell 50488dfb51 refactor: adjust the loading order and output path of theme resources (#635)
* refactor: update config script handling to support dynamic target paths

* refactor: refactor the output paths of the script and style shortcodes, and add test cases

* fix: remove redundant console log in script-style-test.md and update MathJax and Mermaid plugin configurations in assets.html
2025-09-19 11:37:21 +08:00

45 lines
1.0 KiB
JavaScript

const params = window.config.mathjax || {}
/**
* Load MathJax script dynamically
*/
function loadMathJax() {
const script = document.createElement('script')
script.src = params.cdn || 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
script.async = true
document.head.appendChild(script)
}
/**
* Configuring MathJax
* https://docs.mathjax.org/en/latest/options/index.html
*/
window.MathJax = {
tex: {
displayMath: [['\\[', '\\]'], ['$$', '$$']],
inlineMath: [['\\(', '\\)'], ['$', '$']],
packages: {
...params.packages,
},
// custom macros
macros: {
// make \KaTeX command work in MathJax
KaTeX: '{K\\kern-.325em\\raise.21em{\\scriptstyle{A}}\\kern-.17em\\TeX}',
...params.macros,
},
...params.tex,
},
loader: {
...params.loader,
failed: function (error) {
console.error(`MathJax(${error.package || '?'}): ${error.message}`);
},
},
options: {
processHtmlClass: 'content',
...params.options,
}
}
loadMathJax()