mirror of
https://github.com/imfing/hextra.git
synced 2025-08-24 00:46:38 -04:00
feat(math): support local katex assets and improve docs (#742)
* refactor(math): update LaTeX guide and enhance KaTeX integration - Revised the LaTeX documentation for clarity and improved structure, changing section titles and descriptions for better understanding. - Added support for chemistry expressions using the mhchem extension. - Introduced a new KaTeX CSS loader partial to streamline the integration of KaTeX, allowing for configurable remote or local asset loading. - Updated the head partial to utilize the new KaTeX loader, enhancing the flexibility of math rendering options. * refactor(mathjax): simplify MathJax script URL configuration - Removed the dynamic version assignment for MathJax and set a fixed version in the script URL for consistency and clarity. * docs(latex): enhance LaTeX guide and clarify chemistry expressions - Updated section titles for better clarity, changing "Supported Functions" to "Chemistry Expressions." - Improved description of the mhchem extension for rendering chemistry equations. - Removed redundant instructions regarding the passthrough extension in Hugo. - Corrected minor typographical errors in references to MathJax.
This commit is contained in:
@@ -83,27 +83,11 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- KaTeX-->
|
||||
<!-- Math engine -->
|
||||
{{ $noop := .WordCount -}}
|
||||
{{- $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" "") -}}
|
||||
{{ $katexFontPattern := "url(fonts/" }}
|
||||
{{ $katexFontSubstituted := printf "url(%s/fonts/" $katexBaseUrl }}
|
||||
|
||||
{{ with try (resources.GetRemote $katexCssUrl) -}}
|
||||
{{ with .Err -}}
|
||||
{{ errorf "Could not retrieve KaTeX css file from %s. Reason: %s." $katexCssUrl . -}}
|
||||
{{ else with .Value -}}
|
||||
{{ $katexCssContent := strings.Replace .Content $katexFontPattern $katexFontSubstituted }}
|
||||
{{ with resources.FromString (printf "css/katex%s.css" (cond hugo.IsProduction ".min" "")) $katexCssContent -}}
|
||||
{{ $cssHash := . | fingerprint "sha512" -}}
|
||||
<link rel="stylesheet" href="{{- .RelPermalink -}}" integrity="{{- $cssHash.Data.Integrity -}}" crossorigin="anonymous" />
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{ partialCached "scripts/katex.html" . -}}
|
||||
{{ else if and (.Page.Store.Get "hasMath") (eq $engine "mathjax") -}}
|
||||
{{ partialCached "scripts/mathjax.html" . -}}
|
||||
{{ end -}}
|
||||
|
Reference in New Issue
Block a user