mhchem.html 842 B

1234567891011121314
  1. {{/* Add support for displaying chemical equations and physical units by loading the mhchem extension: */ -}}
  2. {{ $mhchem_url := printf "https://cdn.jsdelivr.net/npm/katex@%s/dist/contrib/mhchem%s.js" .version (cond hugo.IsProduction ".min" "") -}}
  3. {{ with try (resources.GetRemote $mhchem_url) -}}
  4. {{ with .Err -}}
  5. {{ errorf "Could not retrieve mhchem script from CDN. Reason: %s." . -}}
  6. {{ else with .Value -}}
  7. {{ with resources.Copy (printf "js/mhchem%s.js" (cond hugo.IsProduction ".min" "")) . }}
  8. {{ $secureJS := . | resources.Fingerprint "sha512" -}}
  9. <script defer src="{{- .RelPermalink -}}" integrity="{{- $secureJS.Data.Integrity -}}" crossorigin="anonymous" ></script>
  10. {{ end -}}
  11. {{ end -}}
  12. {{ else -}}
  13. {{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." .version -}}
  14. {{ end -}}