|
1 | | -{{ $needKaTeX := or .Params.math .Site.Params.katex.enable .Params.chem .Site.Params.chem (.Page.Store.Get "hasKaTeX") (.Page.Store.Get "hasmhchem") -}} |
2 | | -{{ $needmhchem := or .Params.chem .Site.Params.katex.mhchem.enable (.Page.Store.Get "hasmhchem") -}} |
| 1 | +{{ $needKaTeX := or .Site.Params.katex.enable .Params.math .Params.chem -}} |
| 2 | +{{ $needmhchem := or .Site.Params.katex.mhchem.enable .Params.chem -}} |
| 3 | +{{ if ge hugo.Version "0.93.0" -}} |
| 4 | + {{ $needKaTeX = or $needKaTeX (.Page.Store.Get "hasKaTeX") (.Page.Store.Get "hasmhchem") -}} |
| 5 | + {{ $needmhchem = or $needmhchem (.Page.Store.Get "hasmhchem") -}} |
| 6 | +{{ else -}} |
| 7 | + {{ if or $needKaTeX $needmhchem -}} |
| 8 | + {{ warnf "Outdated Hugo version %s, consider upgrading to make full use of all theme features" hugo.Version }} |
| 9 | + {{ end -}} |
| 10 | +{{ end -}} |
3 | 11 |
|
4 | 12 | {{ if .Site.Params.markmap.enable -}} |
5 | 13 | <style> |
|
26 | 34 | <script src='{{ "js/deflate.js" | relURL }}'></script> |
27 | 35 | {{ end -}} |
28 | 36 |
|
29 | | -{{ if $needKaTeX -}} |
30 | | - {{ partial "scripts/katex.html" (dict "mhchem" $needmhchem) -}} |
| 37 | +{{ if $needKaTeX -}} |
| 38 | +{{/* load stylesheet and scripts for KaTeX support */ -}} |
| 39 | +<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.css" |
| 40 | + integrity="sha512-6a/jH+OTfV56Vs9Mm+Kl7ZsXWJRM2+EV+JDrW7HLHaf4OU2+9eLkHKFbzpSSbfJ5b60m+7/tQAevrzu7NP7Q2g==" crossorigin="anonymous"> |
| 41 | + {{/* The loading of KaTeX is deferred to speed up page rendering */ -}} |
| 42 | +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.js" |
| 43 | + integrity="sha512-FkmlbBiAj8fgfoZ8zJ+bZQCU5pdU55irXmJzFF/mXlSvBr2x/gmyLHaRu5iSpcA5Hw6CMLCCFSjB1GmgtNL2Qg==" |
| 44 | + crossorigin="anonymous"> |
| 45 | +</script> |
| 46 | + {{ if $needmhchem -}} |
| 47 | + {{/* To add support for displaying chemical equations and physical units, load the mhchem extension: */ -}} |
| 48 | +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/contrib/mhchem.min.js" |
| 49 | + integrity="sha512-Cl4bz7Rt9ppgcBOQa4z96q3UqAzHgBzNDm66u2+lDe0ZJQu0Fgz+6jO57E+IZqzlhGzfNBY++pg7Ue+iopaLrg==" |
| 50 | + crossorigin="anonymous"> |
| 51 | +</script> |
| 52 | + {{ end -}} |
| 53 | + {{/* To automatically render math in text elements, include the auto-render extension: */ -}} |
| 54 | +<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/contrib/auto-render.min.js" |
| 55 | + integrity="sha512-6bKDPShiPRjAcdeO8T6cedaVEi0pavPbzue/G/ZRiwVlurWZOSZ/vI9fr2lhk8IPXK7z51AZac+zBvZzgDJzDQ==" crossorigin="anonymous" |
| 56 | + {{ printf "onload='renderMathInElement(%s, %s);'" (( $.Page.Site.Params.katex.html_dom_element | default "document.body" ) | safeJS ) ( printf "%s" ( $.Page.Site.Params.katex.options | jsonify )) | safeHTMLAttr }}> |
| 57 | +</script> |
31 | 58 | {{ end -}} |
32 | 59 |
|
33 | 60 | {{ $jsBs := resources.Get "vendor/bootstrap/dist/js/bootstrap.bundle.js" -}} |
|
0 commit comments