Last active
August 29, 2019 16:10
-
-
Save Liam0205/923a5aaa785812eb3578 to your computer and use it in GitHub Desktop.
fixed mathjax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if theme.mathjax and page.mathjax %} | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
tex2jax: { | |
inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
processEscapes: true, | |
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'] | |
} | |
}); | |
</script> | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Queue(function() { | |
var all = MathJax.Hub.getAllJax(), i; | |
for (i=0; i < all.length; i += 1) { | |
all[i].SourceElement().parentNode.className += ' has-jax'; | |
} | |
}); | |
</script> | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
TeX: { equationNumbers: { autoNumber: "AMS" } } | |
}); | |
</script> | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
TeX: { | |
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js"] | |
} | |
}); | |
</script> | |
<script type="text/javascript"> | |
window.addEventListener('DOMContentLoaded', () => { | |
document.querySelectorAll('code').forEach(code => { | |
const text = code.innerHTML; | |
is_inline_math = /^\$(.*)\$$/.exec(text); | |
is_display_math = /^\$\$(.*)\$\$$/ms.exec(text) || /^\\begin\{.+\}(.*)\\end\{.+\}/ms.exec(text); | |
if (is_inline_math || is_display_math) { | |
code.parentElement.classList.add('has-jax'); | |
if (is_inline_math) { | |
code.outerHTML = "<span class=yuuki_mathjax_inline>" + text + "</span>"; | |
} else { | |
code.outerHTML = "<span class=yuuki_mathjax_display>" + text + "</span>"; | |
} | |
} | |
}); | |
}); | |
</script> | |
{% if config.language === 'zh-Hans' %} | |
<script type="text/javascript" src="http://cdn.staticfile.org/mathjax/2.4.0/MathJax.js"></script> | |
<script type="text/javascript" src="http://cdn.staticfile.org/mathjax/2.4.0/config/TeX-AMS-MML_HTMLorMML.js"></script> | |
{% else %} | |
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> | |
{% endif %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
您好,按照这种方法修改了之后,所有的公式都不能编译了。请问有解决方法吗?