From 073191903c305db0c977b8d3e01b96c80805ab3e Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Wed, 9 Sep 2026 14:05:02 +0800 Subject: Add build-time MathML rendering --- README.md | 2 +- hugo.toml | 9 ++++++++- layouts/_markup/render-passthrough.html | 13 +++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 layouts/_markup/render-passthrough.html diff --git a/README.md b/README.md index 953b1a0..8b2d67f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A small, document-first personal site built with Hugo, semantic HTML, and one CS ## Requirements -- Hugo 0.123.7 or newer +- Hugo 0.165.0 or newer - POSIX `sh` - Make diff --git a/hugo.toml b/hugo.toml index 0873861..c266924 100644 --- a/hugo.toml +++ b/hugo.toml @@ -1,6 +1,6 @@ baseURL = "http://localhost:1314/" title = "RICHARD QIN'S HOME PAGE" -languageCode = "en" +locale = "en" defaultContentLanguage = "en" timeZone = "Asia/Shanghai" uglyURLs = true @@ -31,6 +31,13 @@ enableRobotsTXT = false baseName = "rss" [markup] + [markup.goldmark] + [markup.goldmark.extensions] + [markup.goldmark.extensions.passthrough] + enable = true + [markup.goldmark.extensions.passthrough.delimiters] + block = [['$$', '$$']] + inline = [['$', '$']] [markup.highlight] codeFences = false guessSyntax = false diff --git a/layouts/_markup/render-passthrough.html b/layouts/_markup/render-passthrough.html new file mode 100644 index 0000000..4e4e779 --- /dev/null +++ b/layouts/_markup/render-passthrough.html @@ -0,0 +1,13 @@ +{{- $options := dict + "displayMode" (eq .Type "block") + "output" "mathml" + "strict" "error" + "throwOnError" true +-}} +{{- with try (transform.ToMath .Inner $options) -}} + {{- with .Err -}} + {{- errorf "Unable to render mathematical markup at %s: %s" $.Position . -}} + {{- else -}} + {{- .Value -}} + {{- end -}} +{{- end -}} -- cgit v1.2.3