feat: you can use MathJax now

This commit is contained in:
jaxleof
2022-06-23 22:12:15 +08:00
parent 66042aa6aa
commit 47f3cab6a5
2 changed files with 45 additions and 1 deletions

View File

@@ -131,6 +131,12 @@ display block $$ ... $$
![latex example](images/latex_example.png)
## Support MathJax
you can add MathJax:true to frontmatter
```
mathJax: true
```
## config.toml example
```toml

View File

@@ -1,4 +1,4 @@
<script type="application/javascript" src="{{ "js/github-style.js" | absURL }}"></script>
<script type="application/javascript" src="{{ " js/github-style.js" | absURL }}"></script>
{{ if or .Params.math .Site.Params.math }}
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css"
integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
@@ -8,3 +8,41 @@
integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
{{ end }}
{{ if or .Params.MathJax .Site.Params.MathJax}}
<script type="text/javascript" async
src="https://cdn.bootcss.com/mathjax/2.7.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\[\[', '\]\]']],
processEscapes: true,
processEnvironments: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
TeX: {
equationNumbers: { autoNumber: "AMS" },
extensions: ["AMSmath.js", "AMSsymbols.js"]
}
}
});
MathJax.Hub.Queue(function () {
// Fix <code> tags after MathJax finishes running. This is a
// hack to overcome a shortcoming of Markdown. Discussion at
// https://github.com/mojombo/jekyll/issues/199
var all = MathJax.Hub.getAllJax(), i;
for (i = 0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<style>
code.has-jax {
font: inherit;
font-size: 100%;
background: inherit;
border: inherit;
color: #515151;
}
</style>
{{end}}