Add support for KaTeX formule

Per https://www.docsy.dev/docs/adding-content/diagrams-and-formulae/#latex-support-with-katex
we can have formulae. Make it so, and document this in the style guide.
This commit is contained in:
Tim Bannister 2025-01-29 16:14:32 +00:00
parent 4d3749acb9
commit 2108c450f6
No known key found for this signature in database
GPG Key ID: 31BA93F2DB289EFE
2 changed files with 30 additions and 0 deletions

View File

@ -3,6 +3,7 @@ title: Documentation Style Guide
linktitle: Style guide
content_type: concept
weight: 40
math: true
---
<!-- overview -->
@ -317,6 +318,18 @@ kind: Pod
...
```
## Formulae and equations
You can use the Docsy support for [diagrams and formulae](https://www.docsy.dev/docs/adding-content/diagrams-and-formulae/#latex-support-with-katex).
For example: `\\(\frac{7}{9} \sqrt{K^8 s}\\)`, which renders as \\(\frac{7}{9} \sqrt{K^8 s}\\).
Prefer inline formulae where reasonable, but you can use a `math` block if that's likely to help readers.
Read the Docsy guide to find out what you need to change in your page to activate support;
if you have problems, add `math: true` to the page [front matter](https://gohugo.io/content-management/front-matter/)
(you can do this even if you think the automatic activation should be enough).
## Kubernetes.io word list
A list of Kubernetes-specific terms and words to be used consistently across the site.

View File

@ -10,6 +10,23 @@
<script src="https://cdn.jsdelivr.net/npm/mermaid@9.2.2/dist/mermaid.min.js" integrity="sha512-IX+bU+wShHqfqaMHLMrtwi4nK6W/Z+QdZoL4kPNtRxI2wCLyHPMAdl3a43Fv1Foqv4AP+aiW6hg1dcrTt3xc+Q==" crossorigin="anonymous"></script>
{{- end }}
{{ $needKaTeX := or .Site.Params.katex.enable .Params.math .Params.chem -}}
{{ if $needKaTeX -}}
{{/* load stylesheet and scripts for KaTeX support */ -}}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/katex.min.css"
integrity="sha512-6VMVcy7XQNyarhVuiL50FzpgCFKsyTd6YO93aaQEyET+BNaWvj0IgKR86Bf6+AmWczxAcSnL+JGjo+iStgO1gQ==" crossorigin="anonymous">
{{/* The loading of KaTeX is deferred to speed up page rendering */ -}}
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/katex.min.js"
integrity="sha512-b9IKj4LCNrtCPBhceRcoYOHWW/S2q9fpl7iAJlyxYpykRj1SKM7FE9+E0NEnJ8g8ni47LBr2GuX9qzg/xeuwzQ=="
crossorigin="anonymous">
</script>
{{/* To automatically render math in text elements, include the auto-render extension: */ -}}
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/contrib/auto-render.min.js"
integrity="sha512-iWiuBS5nt6r60fCz26Nd0Zqe0nbk1ZTIQbl3Kv7kYsX+yKMUFHzjaH2+AnM6vp2Xs+gNmaBAVWJjSmuPw76Efg==" 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 -}}
{{ $jsBs := resources.Get "vendor/bootstrap/dist/js/bootstrap.bundle.js" -}}
{{ $jsBase := resources.Get "js/base.js" }}
{{ $jsAnchor := resources.Get "js/anchor.js" }}