hexo-theme-butterfly/layout/includes/third-party/math/mathjax.pug
Jerry 543cd94c9f feat: 適配 hexo 5.0.0 的 prismjs, 代碼主題和各項功能
refactor: 移除 代碼default主題
fix: 修復夜間模式下代碼塊有背景的bugs(沒開啟渲染的情況下)
feat: 增加 code font-size配置 close #322
refactor: 更改配置中 code-font 為 code-font-family
feat: Pjax下,刷新頁面時,會滾動到上次瀏覽的位置
fix: 修復mathjax溢出屏幕的Bugs close #321
2020-08-19 00:21:18 +08:00

53 lines
1.8 KiB
Plaintext

//- Mathjax 3
//- http://docs.mathjax.org/en/latest/upgrading/v2.html#changes-in-the-mathjax-api
//- https://github.com/mathjax/MathJax/issues/2209
//- http://docs.mathjax.org/en/latest/options/input/tex.html#the-configuration-block
//- http://docs.mathjax.org/en/latest/web/typeset.html#resetting-automatic-equation-numbering
script.
if (!window.MathJax) {
window.MathJax = {
loader: {
source: {
'[tex]/amsCd': '[tex]/amscd'
}
},
tex: {
inlineMath: [ ['$','$'], ["\\(","\\)"]],
tags: 'ams'
},
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)
}
}, ''],
addClass: [200,() => {
document.querySelectorAll('mjx-container:not([display=\'true\']').forEach( node => {
const target = node.parentNode
if (!target.classList.contains('has-jax')) {
target.classList.add('mathjax-overflow')
}
})
}, '', false]
}
}
}
var script = document.createElement('script')
script.src = '!{theme.CDN.mathjax}'
script.id = 'MathJax-script'
script.async = true
document.head.appendChild(script)
} else {
MathJax.startup.document.state(0)
MathJax.texReset()
MathJax.typeset()
}