mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
committed by
Bjørn Erik Pedersen
parent
14bf9dc700
commit
bc16341ca1
@@ -230,6 +230,8 @@ To use KaTeX instead of MathJax, replace the partial template from [Step 2] with
|
||||
|
||||
The delimiters above must match the delimiters in your site configuration.
|
||||
|
||||
<!--
|
||||
|
||||
## Chemistry
|
||||
|
||||
Both MathJax and KaTeX provide support for chemical equations. For example:
|
||||
@@ -242,6 +244,8 @@ $$C_p[\ce{H2O(l)}] = \pu{75.3 J // mol K}$$
|
||||
|
||||
As shown in [Step 2] above, MathJax supports chemical equations without additional configuration. To add chemistry support to KaTeX, enable the mhchem extension as described in the KaTeX [documentation](https://katex.org/docs/libs).
|
||||
|
||||
-->
|
||||
|
||||
[KaTeX]: https://katex.org/
|
||||
[LaTeX]: https://www.latex-project.org/
|
||||
[MathJax]: https://www.mathjax.org/
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }}
|
||||
{{- with try (transform.ToMath .Inner $opts) }}
|
||||
{{- with .Err }}
|
||||
{{ errorf "Unable to render mathematical markup to HTML using the transform.ToMath function. The KaTeX display engine threw the following error: %s: see %s." . $.Position }}
|
||||
{{- else }}
|
||||
{{- .Value }}
|
||||
{{- $.Page.Store.Set "hasMath" true }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
@@ -34,6 +34,10 @@
|
||||
{{ end }}
|
||||
{{ $t.Stop }}
|
||||
{{ end }}
|
||||
{{ $noop := .WordCount }}
|
||||
{{ if .Page.Store.Get "hasMath" }}
|
||||
<link href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css" rel="stylesheet">
|
||||
{{ end }}
|
||||
{{ partial "layouts/head/head.html" . }}
|
||||
</head>
|
||||
<body class="flex flex-col min-h-full bg-white dark:bg-blue-950">
|
||||
|
||||
Reference in New Issue
Block a user