diff options
author | WingLim <643089849@qq.com> | 2021-05-22 16:05:38 +0300 |
---|---|---|
committer | WingLim <643089849@qq.com> | 2021-05-22 16:05:38 +0300 |
commit | e73f58cf7acac8e989b724406936b5f0b13d1179 (patch) | |
tree | 133f786e48c044fcc35a8f62c214cfabe3af022d | |
parent | c6d95fbbf546b20b78c70a17a421cfe19483c49a (diff) |
feat: add katex support
-rw-r--r-- | exampleSite/content/post/test-katex.md | 35 | ||||
-rw-r--r-- | exampleSite/content/post/test-mathjax.md (renamed from exampleSite/content/post/math-typesetting.md) | 4 | ||||
-rw-r--r-- | layouts/partials/footer.html | 6 |
3 files changed, 43 insertions, 2 deletions
diff --git a/exampleSite/content/post/test-katex.md b/exampleSite/content/post/test-katex.md new file mode 100644 index 0000000..6e15fc9 --- /dev/null +++ b/exampleSite/content/post/test-katex.md @@ -0,0 +1,35 @@ +--- +author: Hugo Authors +title: Katex support +date: 2021-05-22 +description: "KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web." +katex: true +--- + +The following + +$$ \int_{a}^{b} x^2 dx $$ + +Is an integral + +$$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$ + +Enable Katex in the config file by setting the `katex` param to `true`. This will import the necessary Katex CSS/JS. + +See the online reference of [supported TeX functions](https://katex.org/docs/supported.html). + +```latex +Inline math: $ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $ +``` + +Inline math: $ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $ + +```latex +Block math: + +$$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$ +``` + +Block math: + +$$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$
\ No newline at end of file diff --git a/exampleSite/content/post/math-typesetting.md b/exampleSite/content/post/test-mathjax.md index b65cd0e..d9116dc 100644 --- a/exampleSite/content/post/math-typesetting.md +++ b/exampleSite/content/post/test-mathjax.md @@ -1,7 +1,7 @@ --- author: Hugo Authors -title: Math Typesetting with MathJax -date: 2019-03-08 +title: MathJax support +date: 2021-05-22 description: A brief guide to setup MathJax mathjax: true --- diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index ab04728..3544230 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -16,6 +16,12 @@ </script> <script async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.5/es5/tex-mml-chtml.js" integrity="sha256-HGLuEfFcsUJGhvB8cQ8nr0gai9EucOOaIxFw7qxmd+w=" crossorigin="anonymous"></script> {{- end }} + {{- if and (or .Params.katex (and .Site.Params.katex (ne .Params.katex false))) (or .IsPage .IsHome) }} + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.css" integrity="sha384-Um5gpz1odJg5Z4HAmzPtgZKdTBHZdw8S29IecapCSB31ligYPhHQZMIlWLYQGVoc" crossorigin="anonymous"> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/katex.min.js" integrity="sha384-YNHdsYkH6gMx9y3mRkmcJ2mFUjTd0qNQQvY9VYZgQd7DcN7env35GzlmFaZ23JGp" crossorigin="anonymous"></script> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.13.11/dist/contrib/auto-render.min.js" integrity="sha384-vZTG03m+2yp6N6BNi5iM4rW4oIwk5DfcNdFfxkk9ZWpDriOkXX8voJBFrAO7MpVl" crossorigin="anonymous" + onload="renderMathInElement(document.querySelector('.article-post'));"></script> + {{- end }} {{ $features := resources.Get "js/features.js" | minify | fingerprint }} <script async src="{{ $features.RelPermalink }}"></script> </footer>
\ No newline at end of file |