diff --git a/docs/how-to/use-relearn-theme.md b/docs/how-to/use-relearn-theme.md index 623aa970..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 @@ -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: 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: