hugo-geekblog/layouts/shortcodes/katex.html

19 lines
636 B
HTML
Raw Permalink Normal View History

<!-- prettier-ignore-start -->
2022-02-22 15:45:10 +00:00
{{ if not (.Page.Scratch.Get "katex") }}
<!-- Include katex only first time -->
<link
rel="stylesheet"
href="{{ index (index .Site.Data.assets "katex.css") "src" | relURL }}"
/>
<script defer src="{{ index (index .Site.Data.assets "katex.js") "src" | relURL }}"></script>
{{ .Page.Scratch.Set "katex" true }}
{{ end }}
<!-- prettier-ignore-end -->
2022-02-22 15:45:10 +00:00
<span class="gblog-katex {{ with .Get "class" }}{{ . }}{{ end }}">
2022-02-22 15:45:10 +00:00
{{ cond (in .Params "display") "\\[" "\\(" -}}
{{- trim .Inner "\n" -}}
{{- cond (in .Params "display") "\\]" "\\)" -}}
2022-02-22 15:45:10 +00:00
</span>
{{- /* Drop trailing newlines */ -}}