diff options
author | amazingrise <8315221+AmazingRise@users.noreply.github.com> | 2020-04-11 12:51:22 +0300 |
---|---|---|
committer | amazingrise <8315221+AmazingRise@users.noreply.github.com> | 2020-04-11 12:51:22 +0300 |
commit | 1cc64d09b48ab2722d9ca7e12153b33cef18f415 (patch) | |
tree | 2d92eac86edb00ee6a7ad7f8b05f10dfa1eccce2 /layouts | |
parent | 805508325312477bb22fb58ee98543b27287ba5c (diff) |
Add MathJax support.
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/head.html | 4 | ||||
-rw-r--r-- | layouts/partials/mathjax.html | 36 |
2 files changed, 40 insertions, 0 deletions
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index b0481f9..f7dbd1b 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -42,6 +42,10 @@ <script src="{{.Site.BaseURL}}/js/table.js"></script> +{{ if .Params.enableMathJax }} + {{ partial "mathjax.html" . }} +{{ end }} + {{ if and (not (.Params.disableToC) ) (.IsPage) }} <script src="{{.Site.BaseURL}}/js/toc.js"></script> {{ else }} diff --git a/layouts/partials/mathjax.html b/layouts/partials/mathjax.html new file mode 100644 index 0000000..386b8d7 --- /dev/null +++ b/layouts/partials/mathjax.html @@ -0,0 +1,36 @@ +<!-- From https://note.qidong.name/2018/03/hugo-mathjax/ --> +<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> +<script> +MathJax = { + tex: { + inlineMath: [['$', '$'], ['\\(', '\\)']] + }, + svg: { + fontCache: 'global' + } +}; +</script> +<script type="text/javascript" id="MathJax-script" +async +src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.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> + |