From 2949bd273cbdc7f8e99861776ab2233472e76de2 Mon Sep 17 00:00:00 2001 From: Jone Marius Vignes Date: Fri, 12 Jun 2026 13:55:47 +0200 Subject: [PATCH 1/3] fix(hugo): preserve $...$ inline math through Goldmark passthrough Inline math written as $x+x$ was being stripped or re-rendered instead of handed to MathJax, because the Goldmark passthrough extension's inline delimiters only included \\(...\\). Add the standard $...$ pair alongside the existing delimiters, so both conventional inline-math forms pass through to MathJax. Display math ($$...$$ and \\[...\\]) is unaffected and was already working. Closes #62 --- internal/hugo/models/config.go | 2 +- .../hugo/testdata/hugo_config/relearn_custom_taxonomies.yaml | 2 ++ .../hugo/testdata/hugo_config/relearn_default_taxonomies.yaml | 2 ++ test/testdata/golden/conflicting-paths/hugo-config.golden.yaml | 2 ++ test/testdata/golden/cross-repo-links/hugo-config.golden.yaml | 2 ++ .../golden/daemon-public-filter/hugo-config.golden.yaml | 2 ++ test/testdata/golden/deep-nesting/hugo-config.golden.yaml | 2 ++ .../golden/frontmatter-injection/hugo-config.golden.yaml | 2 ++ test/testdata/golden/image-paths/hugo-config.golden.yaml | 2 ++ .../golden/malformed-frontmatter/hugo-config.golden.yaml | 2 ++ test/testdata/golden/menu-generation/hugo-config.golden.yaml | 2 ++ test/testdata/golden/only-readme/hugo-config.golden.yaml | 2 ++ test/testdata/golden/section-indexes/hugo-config.golden.yaml | 2 ++ .../golden/sidebar-group-by-multi-value/hugo-config.golden.yaml | 2 ++ .../sidebar-group-by-sibling-category/hugo-config.golden.yaml | 2 ++ test/testdata/golden/sidebar-group-by/hugo-config.golden.yaml | 2 ++ test/testdata/golden/special-chars/hugo-config.golden.yaml | 2 ++ test/testdata/golden/two-repos/hugo-config.golden.yaml | 2 ++ test/testdata/golden/uid-permalink-ref/hugo-config.golden.yaml | 2 ++ test/testdata/golden/unicode-names/hugo-config.golden.yaml | 2 ++ 20 files changed, 39 insertions(+), 1 deletion(-) diff --git a/internal/hugo/models/config.go b/internal/hugo/models/config.go index 55d9f482..f0d99371 100644 --- a/internal/hugo/models/config.go +++ b/internal/hugo/models/config.go @@ -89,7 +89,7 @@ func (rc *RootConfig) EnableMathPassthrough() { ext["passthrough"] = map[string]any{ "delimiters": map[string]any{ "block": [][]string{{"\\[", "\\]"}, {"$$", "$$"}}, - "inline": [][]string{{"\\(", "\\)"}}, + "inline": [][]string{{"\\(", "\\)"}, {"$", "$"}}, }, "enable": true, } diff --git a/internal/hugo/testdata/hugo_config/relearn_custom_taxonomies.yaml b/internal/hugo/testdata/hugo_config/relearn_custom_taxonomies.yaml index 3566ecd7..125d04ee 100644 --- a/internal/hugo/testdata/hugo_config/relearn_custom_taxonomies.yaml +++ b/internal/hugo/testdata/hugo_config/relearn_custom_taxonomies.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/internal/hugo/testdata/hugo_config/relearn_default_taxonomies.yaml b/internal/hugo/testdata/hugo_config/relearn_default_taxonomies.yaml index 48934b6b..d52c5e32 100644 --- a/internal/hugo/testdata/hugo_config/relearn_default_taxonomies.yaml +++ b/internal/hugo/testdata/hugo_config/relearn_default_taxonomies.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/conflicting-paths/hugo-config.golden.yaml b/test/testdata/golden/conflicting-paths/hugo-config.golden.yaml index 5d99c146..ff07ecf9 100644 --- a/test/testdata/golden/conflicting-paths/hugo-config.golden.yaml +++ b/test/testdata/golden/conflicting-paths/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/cross-repo-links/hugo-config.golden.yaml b/test/testdata/golden/cross-repo-links/hugo-config.golden.yaml index b11ee154..8202d09b 100644 --- a/test/testdata/golden/cross-repo-links/hugo-config.golden.yaml +++ b/test/testdata/golden/cross-repo-links/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/daemon-public-filter/hugo-config.golden.yaml b/test/testdata/golden/daemon-public-filter/hugo-config.golden.yaml index cbd28b8e..6423ca76 100644 --- a/test/testdata/golden/daemon-public-filter/hugo-config.golden.yaml +++ b/test/testdata/golden/daemon-public-filter/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/deep-nesting/hugo-config.golden.yaml b/test/testdata/golden/deep-nesting/hugo-config.golden.yaml index e88f37ee..d2ac0318 100644 --- a/test/testdata/golden/deep-nesting/hugo-config.golden.yaml +++ b/test/testdata/golden/deep-nesting/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/frontmatter-injection/hugo-config.golden.yaml b/test/testdata/golden/frontmatter-injection/hugo-config.golden.yaml index c22e87c8..428e164a 100644 --- a/test/testdata/golden/frontmatter-injection/hugo-config.golden.yaml +++ b/test/testdata/golden/frontmatter-injection/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/image-paths/hugo-config.golden.yaml b/test/testdata/golden/image-paths/hugo-config.golden.yaml index d9d6b840..aa191504 100644 --- a/test/testdata/golden/image-paths/hugo-config.golden.yaml +++ b/test/testdata/golden/image-paths/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/malformed-frontmatter/hugo-config.golden.yaml b/test/testdata/golden/malformed-frontmatter/hugo-config.golden.yaml index 3a23e64b..68be26e2 100644 --- a/test/testdata/golden/malformed-frontmatter/hugo-config.golden.yaml +++ b/test/testdata/golden/malformed-frontmatter/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/menu-generation/hugo-config.golden.yaml b/test/testdata/golden/menu-generation/hugo-config.golden.yaml index 1fd05fae..200e849c 100644 --- a/test/testdata/golden/menu-generation/hugo-config.golden.yaml +++ b/test/testdata/golden/menu-generation/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/only-readme/hugo-config.golden.yaml b/test/testdata/golden/only-readme/hugo-config.golden.yaml index 76ecee06..95749be6 100644 --- a/test/testdata/golden/only-readme/hugo-config.golden.yaml +++ b/test/testdata/golden/only-readme/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/section-indexes/hugo-config.golden.yaml b/test/testdata/golden/section-indexes/hugo-config.golden.yaml index 835a9aa8..540a92ba 100644 --- a/test/testdata/golden/section-indexes/hugo-config.golden.yaml +++ b/test/testdata/golden/section-indexes/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/sidebar-group-by-multi-value/hugo-config.golden.yaml b/test/testdata/golden/sidebar-group-by-multi-value/hugo-config.golden.yaml index 56953028..9fc721bf 100644 --- a/test/testdata/golden/sidebar-group-by-multi-value/hugo-config.golden.yaml +++ b/test/testdata/golden/sidebar-group-by-multi-value/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/sidebar-group-by-sibling-category/hugo-config.golden.yaml b/test/testdata/golden/sidebar-group-by-sibling-category/hugo-config.golden.yaml index 2b0bcfd2..17fc105f 100644 --- a/test/testdata/golden/sidebar-group-by-sibling-category/hugo-config.golden.yaml +++ b/test/testdata/golden/sidebar-group-by-sibling-category/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/sidebar-group-by/hugo-config.golden.yaml b/test/testdata/golden/sidebar-group-by/hugo-config.golden.yaml index 12cca21e..d11492c6 100644 --- a/test/testdata/golden/sidebar-group-by/hugo-config.golden.yaml +++ b/test/testdata/golden/sidebar-group-by/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/special-chars/hugo-config.golden.yaml b/test/testdata/golden/special-chars/hugo-config.golden.yaml index dc9a20be..12246720 100644 --- a/test/testdata/golden/special-chars/hugo-config.golden.yaml +++ b/test/testdata/golden/special-chars/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/two-repos/hugo-config.golden.yaml b/test/testdata/golden/two-repos/hugo-config.golden.yaml index 2f33b274..861cff81 100644 --- a/test/testdata/golden/two-repos/hugo-config.golden.yaml +++ b/test/testdata/golden/two-repos/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/uid-permalink-ref/hugo-config.golden.yaml b/test/testdata/golden/uid-permalink-ref/hugo-config.golden.yaml index c8abe67f..a7ff958f 100644 --- a/test/testdata/golden/uid-permalink-ref/hugo-config.golden.yaml +++ b/test/testdata/golden/uid-permalink-ref/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: diff --git a/test/testdata/golden/unicode-names/hugo-config.golden.yaml b/test/testdata/golden/unicode-names/hugo-config.golden.yaml index 93220716..3c10c42c 100644 --- a/test/testdata/golden/unicode-names/hugo-config.golden.yaml +++ b/test/testdata/golden/unicode-names/hugo-config.golden.yaml @@ -19,6 +19,8 @@ markup: inline: - - \( - \) + - - $ + - $ enable: true parser: attribute: From 0401ce24118c0aa8898d0ac0939d0d14d5a079f4 Mon Sep 17 00:00:00 2001 From: Jone Marius Vignes Date: Fri, 12 Jun 2026 14:02:05 +0200 Subject: [PATCH 2/3] docs(relearn): document math delimiters and $-escape requirement Adding $...$ as an inline math delimiter (the previous commit) means any paired $ in prose is now treated as math. Document the supported delimiter forms and the escape rule for literal $ characters, since this is inherent to the standard math delimiter convention and not a docbuilder-specific quirk. --- docs/how-to/use-relearn-theme.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/how-to/use-relearn-theme.md b/docs/how-to/use-relearn-theme.md index 623aa970..2af48ad6 100644 --- a/docs/how-to/use-relearn-theme.md +++ b/docs/how-to/use-relearn-theme.md @@ -275,6 +275,29 @@ DocBuilder automatically configures these defaults for Relearn: All defaults can be overridden in your configuration's `hugo.params` section. +## Math Support + +Relearn renders mathematical notation through MathJax. DocBuilder wires up the standard delimiter pairs so the following forms all work out of the box: + +| Form | Type | Example | +|------|------|---------| +| `$x + y$` | inline | The sum $x + y$ is positive. | +| `\(x + y\)` | inline | The sum \(x + y\) is positive. | +| `$$x + y$$` | display (block) | $$x + y$$ | +| `\[x + y\]` | display (block) | \[x + y\] | + +### Escaping literal `$` characters + +The `$...$` form is recognised as math whenever a paired `$` is found, so prose that contains a `$` character (currency, shell variables, etc.) will be misread as math. Escape a literal `$` with a backslash when it is **not** meant to start a math span: + +```markdown +It costs \$5 and \$10. + +Use \$HOME or \$TMPDIR for paths. +``` + +If you cannot escape at the source (for example, the `$` appears inside a code-incompatible position), wrap the text in inline code with backticks (`` `$HOME` ``). + ## Hugo Module Configuration DocBuilder uses Hugo Modules to automatically install Relearn. The theme is configured as: From 780325a8a957e52f9bfcd7ebbada6b71f89345e4 Mon Sep 17 00:00:00 2001 From: Jone Marius Vignes Date: Fri, 12 Jun 2026 14:06:01 +0200 Subject: [PATCH 3/3] docs(relearn): refresh frontmatter fingerprint after math section --- docs/how-to/use-relearn-theme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/how-to/use-relearn-theme.md b/docs/how-to/use-relearn-theme.md index 2af48ad6..06377734 100644 --- a/docs/how-to/use-relearn-theme.md +++ b/docs/how-to/use-relearn-theme.md @@ -5,8 +5,8 @@ categories: - how-to date: 2025-12-15T00:00:00Z description: Relearn theme overview -fingerprint: cad2b47a3afbbaf3e8f319d590ab1cf4d438535b3359485a2f8ca82a61db435e -lastmod: "2026-01-22" +fingerprint: 39f4157cdb927c0f651edabb9972670c6f58507b3f9bc8ec6d8e6e5f77d4ecaf +lastmod: "2026-06-12" tags: - themes - relearn