mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
fix: 修復首頁文章 valine 評論數只顯示第一篇的 bug fix: 修復子目錄下,第三方插件本地資源無法加載的 bug closed #908 fix: 評論系統開啟時 busuanzi 的 page_pv 不顯示的 bug closed #902 fix: 修復 pjax 下,使用 mermaid 跳轉會重新加載的 bug
48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
//- Mathjax 3
|
|
script.
|
|
if (!window.MathJax) {
|
|
window.MathJax = {
|
|
tex: {
|
|
inlineMath: [ ['$','$'], ["\\(","\\)"]],
|
|
tags: 'ams'
|
|
},
|
|
chtml: {
|
|
scale: 1.2
|
|
},
|
|
options: {
|
|
renderActions: {
|
|
findScript: [10, doc => {
|
|
for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
|
|
const display = !!node.type.match(/; *mode=display/)
|
|
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
|
|
const text = document.createTextNode('')
|
|
node.parentNode.replaceChild(text, node)
|
|
math.start = {node: text, delim: '', n: 0}
|
|
math.end = {node: text, delim: '', n: 0}
|
|
doc.math.push(math)
|
|
}
|
|
}, ''],
|
|
insertScript: [200, () => {
|
|
document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
|
|
const target = node.parentNode
|
|
if (target.nodeName.toLowerCase() === 'li') {
|
|
target.parentNode.classList.add('has-jax')
|
|
} else {
|
|
target.classList.add('has-jax')
|
|
}
|
|
});
|
|
}, '', false]
|
|
}
|
|
}
|
|
}
|
|
|
|
const script = document.createElement('script')
|
|
script.src = '!{url_for(theme.asset.mathjax)}'
|
|
script.id = 'MathJax-script'
|
|
script.async = true
|
|
document.head.appendChild(script)
|
|
} else {
|
|
MathJax.startup.document.state(0)
|
|
MathJax.texReset()
|
|
MathJax.typeset()
|
|
} |