mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
50488dfb51
* 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
45 lines
1.0 KiB
JavaScript
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()
|