I create render-passthrough.html like this:
{{- if site.params.math.type "katex" -}}
{{/* for KaTeX server-side rendering */}}
{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq $.Type "block") }}
{{- with try (transform.ToMath .Inner $opts) }}
{{- with .Err }}
{{- warnf "Unable to render mathematical markup to HTML using the transform.ToMath function. The KaTeX display engine threw the following error: %s: see %s." . $.Position }}
{{- if eq $.Type "block" -}}
<p><mark class="text-danger">KaTeX parse error!</mark></p>
{{- else -}}
<mark class="text-danger">KaTeX parse error!</mark>
{{- end -}}
{{- else }}
{{- .Value }}
{{- $.Page.Store.Set "hasMath" true -}}
{{- end }}
{{- end -}}
{{- else -}}
{{/* TODO keep original output of Hugo rendering, maybe a .Delimiters is needed? (like: .Delimiters => ['$$', '$$']) */}}
{{/* $delimiters := .Delimiters */}}
{{- end -}}
for example, if the markdown input is: $$c = \pm\sqrt{a^2 + b^2}$$
and no render-passthrough.html
file is found, the output will be: $$c = \pm\sqrt{a^2 + b^2}$$
.
however, if I defined render-passthrough.html
, I can’t get the delimiters.
If I could obtain delimiters in render-passthrough.html, I could do more than just render Katex math.