⚡ Improved the comments plug-in load function, close #12
This commit is contained in:
7
static/js/third-party/math/katex.js
vendored
Normal file
7
static/js/third-party/math/katex.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/* global NexT, CONFIG */
|
||||
|
||||
document.addEventListener('page:loaded', () => {
|
||||
if (!CONFIG.enableMath) return;
|
||||
|
||||
NexT.utils.getScript(CONFIG.katex.copy_tex_js).catch(() => {});
|
||||
});
|
||||
36
static/js/third-party/math/mathjax.js
vendored
Normal file
36
static/js/third-party/math/mathjax.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/* global NexT, CONFIG, MathJax */
|
||||
|
||||
document.addEventListener('page:loaded', () => {
|
||||
if (!CONFIG.enableMath) return;
|
||||
|
||||
if (typeof MathJax === 'undefined') {
|
||||
window.MathJax = {
|
||||
tex: {
|
||||
inlineMath: { '[+]': [['$', '$']] },
|
||||
tags : CONFIG.mathjax.tags
|
||||
},
|
||||
options: {
|
||||
renderActions: {
|
||||
insertedScript: [200, () => {
|
||||
document.querySelectorAll('mjx-container').forEach(node => {
|
||||
const target = node.parentNode;
|
||||
if (target.nodeName.toLowerCase() === 'li') {
|
||||
target.parentNode.classList.add('has-jax');
|
||||
}
|
||||
});
|
||||
}, '', false]
|
||||
}
|
||||
}
|
||||
};
|
||||
NexT.utils.getScript(CONFIG.mathjax.js, {
|
||||
attributes: {
|
||||
defer: true
|
||||
}
|
||||
});
|
||||
} else {
|
||||
MathJax.startup.document.state(0);
|
||||
MathJax.typesetClear();
|
||||
MathJax.texReset();
|
||||
MathJax.typesetPromise();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user