From 778f735cd473eb07ebf138e407685cd81ddd25e4 Mon Sep 17 00:00:00 2001 From: Kirill Bobyrev Date: Sat, 27 Jan 2024 16:12:38 -0800 Subject: [PATCH] Update KaTeX integration to setup recommended in Hugo 0.122 --- assets/css/style.css | 2 +- exampleSite/content/features/extensions.md | 4 +++- exampleSite/hugo.toml | 7 ++++++ layouts/partials/head.html | 2 +- layouts/partials/math.html | 26 +++++++++++++--------- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 7743999..7f2cf93 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -85,7 +85,7 @@ hr { pre:has(code), p>code { border: thin solid var(--muted); padding: .5rem; - border-radius: 0.5rem; + border-radius: 0.3rem; overflow-x: auto; } diff --git a/exampleSite/content/features/extensions.md b/exampleSite/content/features/extensions.md index 0387e1d..199c23e 100644 --- a/exampleSite/content/features/extensions.md +++ b/exampleSite/content/features/extensions.md @@ -82,12 +82,14 @@ Please press Ctrl + Shift + R If you want to use KaTeX-based math rendering in your posts, set `math = true` in the post front matter or in the site config. Then you can use LaTeX syntax to -write math equations (`$$` for display mode, `$` for inline mode): +write math equations (`$$` for display mode, `\(` and `\)` for inline mode): $$ i \hbar \frac{\partial}{\partial t}\Psi(\mathbf{r},t) = \hat H \Psi(\mathbf{r},t) $$ +And also \(x = 42\) for inline equations. + ## Default Hugo shortcodes You can use all the [built-in Hugo diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 429ba62..ffaaf7a 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -15,3 +15,10 @@ themesDir = '../..' guessSyntax = true style = 'github' tabWidth = 2 + [markup.goldmark] + [markup.goldmark.extensions] + [markup.goldmark.extensions.passthrough] + enable = true + [markup.goldmark.extensions.passthrough.delimiters] + block = [['\[', '\]'], ['$$', '$$']] + inline = [['\(', '\)']] diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 900c652..797c9c8 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -55,5 +55,5 @@ {{ end }} {{ if or .Params.math site.Params.math }} -{{ partial "math.html" . }} +{{ partialCached "math.html" . }} {{ end }} diff --git a/layouts/partials/math.html b/layouts/partials/math.html index 87db910..aaa7e17 100644 --- a/layouts/partials/math.html +++ b/layouts/partials/math.html @@ -1,11 +1,15 @@ - - - - - - - + + + +