diff options
author | puresyntax71 <34715246+puresyntax71@users.noreply.github.com> | 2020-11-13 06:56:09 +0300 |
---|---|---|
committer | puresyntax71 <34715246+puresyntax71@users.noreply.github.com> | 2020-11-13 06:56:09 +0300 |
commit | 226066dfa18b7c93ef14d32c86d74f2315751f1f (patch) | |
tree | 86a586e0938299d4b7ea35dde56ea79122d3583b | |
parent | 4c873e910392acae5e4b9c218a1e33dc0a9950ff (diff) |
Fixes #94.
-rw-r--r--[-rwxr-xr-x] | exampleSite/content/post/math-typesetting.md (renamed from exampleSite/content/post/math-typesetting.mmark) | 27 | ||||
-rw-r--r-- | exampleSite/layouts/partials/foot.html | 24 | ||||
-rw-r--r-- | exampleSite/layouts/partials/math.html | 4 |
3 files changed, 43 insertions, 12 deletions
diff --git a/exampleSite/content/post/math-typesetting.mmark b/exampleSite/content/post/math-typesetting.md index 23ddd92..9305dd7 100755..100644 --- a/exampleSite/content/post/math-typesetting.mmark +++ b/exampleSite/content/post/math-typesetting.md @@ -1,13 +1,12 @@ --- authors: - - "Hugo Authors" + - Hugo Authors title: Math Typesetting date: 2019-03-08 description: A brief guide to setup KaTeX -markup: mmark math: true images: - - math-typesetting.jpg + - math-typesetting.jpg --- Mathematical notation in a Hugo project can be enabled by using third party JavaScript libraries. @@ -19,31 +18,35 @@ In this example we will be using [KaTeX](https://katex.org/) - Within this partial reference the [Auto-render Extension](https://katex.org/docs/autorender.html) or host these scripts locally. - Include the partial in your templates like so: -``` +```bash {{ if or .Params.math .Site.Params.math }} {{ partial "math.html" . }} {{ end }} -``` +``` + - To enable KaTex globally set the parameter `math` to `true` in a project's configuration -- To enable KaTex on a per page basis include the parameter `math: true` in content files. +- To enable KaTex on a per page basis include the parameter `math: true` in content files **Note:** Use the online reference of [Supported TeX Functions](https://katex.org/docs/supported.html) + {{< math.inline >}} {{ if or .Page.Params.math .Site.Params.math }} <!-- KaTeX --> -<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous"> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script> -<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script> +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous"> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script> {{ end }} {{</ math.inline >}} ### Examples -Inline math: $$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$ +{{< math.inline >}} +<p> +Inline math: \(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\) +</p> +{{</ math.inline >}} Block math: - $$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$ - diff --git a/exampleSite/layouts/partials/foot.html b/exampleSite/layouts/partials/foot.html new file mode 100644 index 0000000..6627b41 --- /dev/null +++ b/exampleSite/layouts/partials/foot.html @@ -0,0 +1,24 @@ +{{ with index .Site.Data "chunky-poster" }} + {{ range $vendor := .assets }} + {{ if $vendor.js }} + <script src="{{ print "dist/" $vendor.js | relURL }}"></script> + {{ end }} + {{ end }} +{{ end }} + +{{ if .Site.Params.prismJS.enable }} +<script> + window.Prism = window.Prism || {}; + window.Prism.manual = true; +</script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/components/prism-core.min.js"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autoloader/prism-autoloader.min.js"></script> +{{ end }} + +{{ range .Site.Params.customJS -}} + <script src="{{ "js/" | relURL }}{{ . }}"></script> +{{ end }} + +{{ if or .Params.math .Site.Params.math }} + {{ partial "math.html" . }} +{{ end }} diff --git a/exampleSite/layouts/partials/math.html b/exampleSite/layouts/partials/math.html new file mode 100644 index 0000000..6bb6143 --- /dev/null +++ b/exampleSite/layouts/partials/math.html @@ -0,0 +1,4 @@ +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous"> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script> +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" + onload="renderMathInElement(document.body);"></script> |