Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zwbetz-gh/vanilla-bootstrap-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzwbetz-gh <37317628+zwbetz-gh@users.noreply.github.com>2020-02-29 06:01:01 +0300
committerGitHub <noreply@github.com>2020-02-29 06:01:01 +0300
commitc9a46a20de130af8a38a755857fcade56e1028cc (patch)
treee4326f45303a4d7431e98cc63669fc0bf2698892
parent92eaa26a8e76edb065de4e01619d1c30e9bb1fe0 (diff)
add katex support (#17)
-rw-r--r--exampleSite/config.yaml1
-rw-r--r--exampleSite/content/post/katex-math-typesetting/index.md29
-rw-r--r--layouts/_default/baseof.html1
-rw-r--r--layouts/partials/katex.html27
4 files changed, 58 insertions, 0 deletions
diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml
index d06df68..7ad9115 100644
--- a/exampleSite/config.yaml
+++ b/exampleSite/config.yaml
@@ -43,6 +43,7 @@ params:
homeText: Welcome to the Vanilla theme demo. Have a look around. Maybe even eat some ice cream.
footerText: Made with [Hugo](https://gohugo.io/) & [Vanilla](https://github.com/zwbetz-gh/vanilla-bootstrap-hugo-theme)
hideFooter: false
+ katex: true
markup:
defaultMarkdownHandler: goldmark
diff --git a/exampleSite/content/post/katex-math-typesetting/index.md b/exampleSite/content/post/katex-math-typesetting/index.md
new file mode 100644
index 0000000..1ce7702
--- /dev/null
+++ b/exampleSite/content/post/katex-math-typesetting/index.md
@@ -0,0 +1,29 @@
+---
+title: "Katex Math Typesetting"
+date: 2020-02-28
+tags: [katex, math, typesetting, hugo]
+---
+
+Enable Katex in the config file by setting the `katex` param to `true`. This will import the necessary Katex CSS/JS.
+
+**Note:** Use the online reference of [supported TeX functions](https://katex.org/docs/supported.html).
+
+Some math:
+
+```
+$$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$
+```
+
+$$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$
+
+More math:
+
+```
+$$
+\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
+$$
+```
+
+$$
+\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
+$$
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 7d81159..83873bd 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -11,6 +11,7 @@
</div>
{{ partial "footer.html" . }}
{{ partial "script.html" . }}
+ {{ partial "katex.html" . }}
{{ partial "google-analytics-async.html" . }}
</body>
</html> \ No newline at end of file
diff --git a/layouts/partials/katex.html b/layouts/partials/katex.html
new file mode 100644
index 0000000..b7e5989
--- /dev/null
+++ b/layouts/partials/katex.html
@@ -0,0 +1,27 @@
+<!-- https://katex.org/docs/browser.html -->
+
+{{ if eq site.Params.katex true }}
+<link
+ rel="stylesheet"
+ href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css"
+ integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq"
+ crossorigin="anonymous"
+/>
+
+<!-- The loading of KaTeX is deferred to speed up page rendering -->
+<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>
+
+<!-- To automatically render math in text elements, include the auto-render extension: -->
+<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 }}