Add support for MathJax

This commit is contained in:
Chuyang Chen 2022-06-10 22:01:20 +08:00
parent 769fbb55e3
commit 8aac26a42b
3 changed files with 31 additions and 0 deletions

View File

@ -508,6 +508,13 @@ article figcaption {
margin-bottom: 2em;
}
code.has-jax {
-webkit-font-smoothing: antialiased;
background: inherit !important;
border: none !important;
font-size: 100%;
}
.read-more {
margin: 1em 0;
}

View File

@ -13,4 +13,6 @@
<nav></nav>
{{ end }}
{{ if .Site.Params.mathjax }}{{ partial "mathjax_support.html" . }}{{ end }}
{{ partial "header-extra.html" . }}

View File

@ -0,0 +1,22 @@
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$','$$'], ['\\[', '\\]']],
processEscapes: true,
processEnvironments: true
},
options: {
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
};
window.addEventListener('load', (event) => {
document.querySelectorAll("mjx-container").forEach(function(x){
x.parentElement.classList += 'has-jax'})
});
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>