Skip to content

Retrieving KaTeX resources via GetRemote: improved error handling #2281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions layouts/_partials/scripts/katex.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
{{ $secureCSS := . | resources.Fingerprint "sha512" -}}
<link rel="stylesheet" href="{{- .RelPermalink -}}" integrity="{{- $secureCSS.Data.Integrity -}}" crossorigin="anonymous">
{{ end -}}
{{ else -}}
{{ errorf "Could not retrieve css file %q from CDN. Reason: invalid KaTeX version %q." $katex_css_url $version -}}
{{ end -}}
{{ else -}}
{{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." $version -}}
{{ end -}}

{{/* The loading of KaTeX is deferred to speed up page rendering */ -}}
Expand All @@ -26,9 +26,9 @@
{{ $secureJS := . | resources.Fingerprint "sha512" -}}
<script defer src="{{- .RelPermalink -}}" integrity="{{- $secureJS.Data.Integrity -}}" crossorigin="anonymous" ></script>
{{ end -}}
{{ else -}}
{{ errorf "Could not retrieve javascript file %q from CDN. Reason: invalid KaTeX version %q." $katex_js_url $version -}}
{{ end -}}
{{ else -}}
{{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." $version -}}
{{ end -}}

{{/* Add support for displaying chemical equations and physical units by loading the mhchem extension: */ -}}
Expand All @@ -49,7 +49,7 @@
{{ 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 -}} >
</script>
{{ end -}}
{{ else -}}
{{ errorf "Could not retrieve autorender extension %q from CDN. Reason: invalid KaTeX version %q." $katex_autorender_url $version -}}
{{ end -}}
{{ else -}}
{{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." $version -}}
{{ end -}}
4 changes: 2 additions & 2 deletions layouts/_partials/scripts/mhchem.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{ $secureJS := . | resources.Fingerprint "sha512" -}}
<script defer src="{{- .RelPermalink -}}" integrity="{{- $secureJS.Data.Integrity -}}" crossorigin="anonymous" ></script>
{{ end -}}
{{ else -}}
{{ errorf "Could not retrieve mhchem extension %q from CDN. Reason: invalid KaTeX version %q." $mhchem_url $.version -}}
{{ end -}}
{{ else -}}
{{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." .version -}}
{{ end -}}