hexo-blog-deploy/js/third-party/math/mathjax.js

37 lines
934 B
JavaScript
Raw Normal View History

2023-04-26 06:12:09 +00:00
/* 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();
}
});