Add mathjax support

This commit is contained in:
Hanwen Guo 2022-08-26 17:51:29 +08:00
parent d4fc55a757
commit 0374aa92bf
3 changed files with 31 additions and 2 deletions

View File

@ -76,6 +76,13 @@ code {
background: black;
}
code.has-jax {
-webkit-font-smoothing: antialiased;
background: inherit !important;
border: none !important;
font-size: 100%;
}
blockquote {
font-style: italic;
border: thin solid black;
@ -88,4 +95,4 @@ img {
max-width: 100%;
display: block;
margin: 0 auto;
}
}

View File

@ -17,4 +17,5 @@
{{ $sass := resources.Get "css/main.scss" }}
{{ $style := $sass | resources.ToCSS $options }}
<link rel="stylesheet" href="{{ $style.Permalink | relURL }}" />
</head>
{{ if .Params.mathjax }} {{ partial "mathjax.html" . }} {{ end }}
</head>

View File

@ -0,0 +1,21 @@
<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 id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>