mirror of
https://github.com/imfing/hextra.git
synced 2025-08-23 16:36:44 -04:00
feat(math): add optional MathJax support (#707)
* feat: add MathJax option * docs: move math engine note * refactor: update LaTeX documentation and improve MathJax integration - Adjusted LaTeX documentation for clarity and formatting. - Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering. - Removed deprecated comments and streamlined the script loading process for MathJax. - Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions. * docs: simplify LaTeX documentation and clarify configuration steps - Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation. - Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo. - Enhanced MathJax section to emphasize its use as an alternative rendering engine.
This commit is contained in:
@@ -85,7 +85,8 @@
|
||||
|
||||
<!-- KaTeX-->
|
||||
{{ $noop := .WordCount -}}
|
||||
{{ if .Page.Store.Get "hasMath" -}}
|
||||
{{- $engine := site.Params.math.engine | default "katex" -}}
|
||||
{{ if and (.Page.Store.Get "hasMath") (eq $engine "katex") -}}
|
||||
<!-- TODO: make url configurable -->
|
||||
{{ $katexBaseUrl := "https://cdn.jsdelivr.net/npm/katex@latest/dist" }}
|
||||
{{ $katexCssUrl := printf "%s/katex%s.css" $katexBaseUrl (cond hugo.IsProduction ".min" "") -}}
|
||||
@@ -103,6 +104,8 @@
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ else if and (.Page.Store.Get "hasMath") (eq $engine "mathjax") -}}
|
||||
{{ partialCached "scripts/mathjax.html" . -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ partial "custom/head-end.html" . -}}
|
||||
|
21
layouts/_partials/scripts/mathjax.html
Normal file
21
layouts/_partials/scripts/mathjax.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{{/* MathJax */}}
|
||||
{{ $mathjaxVersion := site.Params.math.mathjaxVersion | default "3" -}}
|
||||
{{ $mathjaxJsUrl := printf "https://cdn.jsdelivr.net/npm/mathjax@%s/es5/tex-chtml.js" $mathjaxVersion -}}
|
||||
<script defer id="MathJax-script" src="{{ $mathjaxJsUrl }}" crossorigin="anonymous" async></script>
|
||||
<script>
|
||||
MathJax = {
|
||||
loader: {
|
||||
load: ["ui/safe"],
|
||||
},
|
||||
tex: {
|
||||
displayMath: [
|
||||
["\\[", "\\]"],
|
||||
["$$", "$$"],
|
||||
],
|
||||
inlineMath: [
|
||||
["\\(", "\\)"],
|
||||
["$", "$"],
|
||||
],
|
||||
},
|
||||
};
|
||||
</script>
|
@@ -1,7 +1,7 @@
|
||||
<p class="hx:opacity-50 hx:text-sm hx:leading-7">
|
||||
{{- range $tag := .Params.tags -}}
|
||||
{{- with $.Site.GetPage (printf "/tags/%s" $tag) -}}
|
||||
<a class="hx:inline-block hx:mr-2" href="{{ .RelPermalink }}">#{{ .Title }}</a>
|
||||
{{- range $tag := .Params.tags -}}
|
||||
{{- with $.Site.GetPage (printf "/tags/%s" $tag) -}}
|
||||
<a class="hx:inline-block hx:mr-2" href="{{ .RelPermalink }}">#{{ .Title }}</a>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</p>
|
||||
</p>
|
||||
|
Reference in New Issue
Block a user