Skip to content
Merged
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
35 changes: 4 additions & 31 deletions layouts/_partials/scripts.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{{ $needKaTeX := or .Site.Params.katex.enable .Params.math .Params.chem -}}
{{ $needmhchem := or .Site.Params.katex.mhchem.enable .Params.chem -}}
{{ if ge hugo.Version "0.93.0" -}}
{{ $needKaTeX = or $needKaTeX (.Page.Store.Get "hasKaTeX") (.Page.Store.Get "hasmhchem") -}}
{{ $needmhchem = or $needmhchem (.Page.Store.Get "hasmhchem") -}}
{{ else -}}
{{ if or $needKaTeX $needmhchem -}}
{{ warnf "Outdated Hugo version %s, consider upgrading to make full use of all theme features" hugo.Version }}
{{ end -}}
{{ end -}}
{{ $needKaTeX := or .Params.math .Site.Params.katex.enable .Params.chem .Site.Params.chem (.Page.Store.Get "hasKaTeX") (.Page.Store.Get "hasmhchem") -}}
{{ $needmhchem := or .Params.chem .Site.Params.katex.mhchem.enable (.Page.Store.Get "hasmhchem") -}}

{{ if .Site.Params.markmap.enable -}}
<style>
Expand All @@ -34,27 +26,8 @@
<script src='{{ "js/deflate.js" | relURL }}'></script>
{{ end -}}

{{ if $needKaTeX -}}
{{/* load stylesheet and scripts for KaTeX support */ -}}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.css"
integrity="sha512-6a/jH+OTfV56Vs9Mm+Kl7ZsXWJRM2+EV+JDrW7HLHaf4OU2+9eLkHKFbzpSSbfJ5b60m+7/tQAevrzu7NP7Q2g==" crossorigin="anonymous">
{{/* The loading of KaTeX is deferred to speed up page rendering */ -}}
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/katex.min.js"
integrity="sha512-FkmlbBiAj8fgfoZ8zJ+bZQCU5pdU55irXmJzFF/mXlSvBr2x/gmyLHaRu5iSpcA5Hw6CMLCCFSjB1GmgtNL2Qg=="
crossorigin="anonymous">
</script>
{{ if $needmhchem -}}
{{/* To add support for displaying chemical equations and physical units, load the mhchem extension: */ -}}
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/contrib/mhchem.min.js"
integrity="sha512-Cl4bz7Rt9ppgcBOQa4z96q3UqAzHgBzNDm66u2+lDe0ZJQu0Fgz+6jO57E+IZqzlhGzfNBY++pg7Ue+iopaLrg=="
crossorigin="anonymous">
</script>
{{ end -}}
{{/* To automatically render math in text elements, include the auto-render extension: */ -}}
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.19/dist/contrib/auto-render.min.js"
integrity="sha512-6bKDPShiPRjAcdeO8T6cedaVEi0pavPbzue/G/ZRiwVlurWZOSZ/vI9fr2lhk8IPXK7z51AZac+zBvZzgDJzDQ==" crossorigin="anonymous"
{{ 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>
{{ if $needKaTeX -}}
{{ partial "scripts/katex.html" (dict "mhchem" $needmhchem) -}}
{{ end -}}

{{ $jsBs := resources.Get "vendor/bootstrap/dist/js/bootstrap.bundle.js" -}}
Expand Down
55 changes: 55 additions & 0 deletions layouts/_partials/scripts/katex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{ $version := .Site.Params.katex.version | default "latest" -}}

{{/* load stylesheet and scripts for KaTeX support */ -}}
{{ $katex_css_url := printf "https://cdn.jsdelivr.net/npm/katex@%s/dist/katex%s.css" $version (cond hugo.IsProduction ".min" "") -}}

{{ with try (resources.GetRemote $katex_css_url) -}}
{{ with .Err -}}
{{ errorf "Could not retrieve KaTeX css file from CDN. Reason: %s." . -}}
{{ else with.Value -}}
{{ with resources.Copy (printf "css/katex%s.css" (cond hugo.IsProduction ".min" "")) . }}
{{ $secureCSS := . | resources.Fingerprint "sha512" -}}
<link rel="stylesheet" href="{{- .RelPermalink -}}" integrity="{{- $secureCSS.Data.Integrity -}}" crossorigin="anonymous">
{{ end -}}
{{ 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 */ -}}
{{ $katex_js_url := printf "https://cdn.jsdelivr.net/npm/katex@%s/dist/katex%s.js" $version (cond hugo.IsProduction ".min" "") -}}
{{ with try (resources.GetRemote $katex_js_url) -}}
{{ with .Err -}}
{{ errorf "Could not retrieve KaTeX script from CDN. Reason: %s." . -}}
{{ else with.Value -}}
{{ with resources.Copy (printf "js/katex%s.js" (cond hugo.IsProduction ".min" "")) . }}
{{ $secureJS := . | resources.Fingerprint "sha512" -}}
<script defer src="{{- .RelPermalink -}}" integrity="{{- $secureJS.Data.Integrity -}}" crossorigin="anonymous" ></script>
{{ end -}}
{{ 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: */ -}}
{{ if .mhchem -}}
{{ partial "scripts/mhchem.html" (dict "version" $version) -}}
{{ end -}}

{{/* To automatically render math in text elements, include the auto-render extension: */ -}}

{{ $katex_autorender_url := printf "https://cdn.jsdelivr.net/npm/katex@%s/dist/contrib/auto-render%s.js" $version (cond hugo.IsProduction ".min" "") -}}
{{ with try (resources.GetRemote $katex_autorender_url) -}}
{{ with .Err -}}
{{ errorf "Could not retrieve KaTeX auto render extension from CDN. Reason: %s." . -}}
{{ else with .Value -}}
{{ with resources.Copy ( printf "js/auto-render%s.js" (cond hugo.IsProduction ".min" "")) . }}
{{ $secureJS := . | resources.Fingerprint "sha512" -}}
<script defer src="{{- .RelPermalink -}}" integrity="{{- $secureJS.Data.Integrity -}}" crossorigin="anonymous"
{{ 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 -}}
{{ end -}}
{{ else -}}
{{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." $version -}}
{{ end -}}
14 changes: 14 additions & 0 deletions layouts/_partials/scripts/mhchem.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{/* Add support for displaying chemical equations and physical units by loading the mhchem extension: */ -}}
{{ $mhchem_url := printf "https://cdn.jsdelivr.net/npm/katex@%s/dist/contrib/mhchem%s.js" .version (cond hugo.IsProduction ".min" "") -}}
{{ with try (resources.GetRemote $mhchem_url) -}}
{{ with .Err -}}
{{ errorf "Could not retrieve mhchem script from CDN. Reason: %s." . -}}
{{ else with .Value -}}
{{ with resources.Copy (printf "js/mhchem%s.js" (cond hugo.IsProduction ".min" "")) . }}
{{ $secureJS := . | resources.Fingerprint "sha512" -}}
<script defer src="{{- .RelPermalink -}}" integrity="{{- $secureJS.Data.Integrity -}}" crossorigin="anonymous" ></script>
{{ end -}}
{{ end -}}
{{ else -}}
{{ errorf "Invalid KaTeX version %s, could not retrieve this version from CDN." .version -}}
{{ end -}}
12 changes: 6 additions & 6 deletions userguide/content/en/blog/2023/bootstrap-5-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ For details and an example, see:

- [Sass](https://getbootstrap.com/docs/5.2/migration/#sass) section of the
migration page
- [\[BSv5\] Adjust `media-breakpoint-down()` argument · Docsy PR #1367](https://github.com/google/docsy/pull/1367)
- [[BSv5] Adjust `media-breakpoint-down()` argument · Docsy PR #1367](https://github.com/google/docsy/pull/1367)

### Grid `.row` and `.col` style changes are breaking

Expand Down Expand Up @@ -111,11 +111,11 @@ updates and might impact Docsy-based projects as well:

References:

- [\[BSv5\] Row/col formatting breaks Docsy components #1466](https://github.com/google/docsy/issues/1466),
- [[BSv5] Row/col formatting breaks Docsy components #1466](https://github.com/google/docsy/issues/1466),
in particular
- [\[BSv5\] Footer fixes: reset flex-shrink, and more·](https://github.com/google/docsy/pull/1373)
- [[BSv5] Footer fixes: reset flex-shrink, and more·](https://github.com/google/docsy/pull/1373)
[Docsy PR](https://github.com/google/docsy/pull/1367)[ #1373](https://github.com/google/docsy/pull/1373)
- [\[BSv5\] Footer: drop flex-shrink tweak + other adjustments ·](https://github.com/google/docsy/pull/1523)
- [[BSv5] Footer: drop flex-shrink tweak + other adjustments ·](https://github.com/google/docsy/pull/1523)
[Docsy PR](https://github.com/google/docsy/pull/1367)[ #1523](https://github.com/google/docsy/pull/1523)
- [Why are all col classes 'position: relative'? · Bootstrap v4 issue #25254](https://github.com/twbs/bootstrap/issues/25254)
- [Why flex-shrink 0 for all columns? · Bootstrap discussion #37951](https://github.com/orgs/twbs/discussions/37951)
Expand Down Expand Up @@ -165,7 +165,7 @@ imports from

References:

- [\[BSv5\] Fix SCSS functions import issue ... ·](https://github.com/google/docsy/pull/1388)
- [[BSv5] Fix SCSS functions import issue ... ·](https://github.com/google/docsy/pull/1388)
[Docsy PR](https://github.com/google/docsy/pull/1367)
[#1388](https://github.com/google/docsy/pull/1388)
- [New \_maps.scss](https://getbootstrap.com/docs/5.2/migration/#new-_mapsscss)
Expand Down Expand Up @@ -227,7 +227,7 @@ Docsy house cleaning. For details concerning both breaking and non-breaking
Docsy-specific changes, consult the
[changelog](https://github.com/google/docsy/blob/main/CHANGELOG.md#070). In
particular, one non-breaking but important change to be aware of is:
[\[BSv5\] Docsy variables cleanup ... PR #1462](https://github.com/google/docsy/pull/1462).
[[BSv5] Docsy variables cleanup ... PR #1462](https://github.com/google/docsy/pull/1462).

## Give it a try!

Expand Down
Loading