Skip to content

Commit 2108c45

Browse files
author
Tim Bannister
committed
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.
1 parent 4d3749a commit 2108c45

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

content/en/docs/contribute/style/style-guide.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Documentation Style Guide
33
linktitle: Style guide
44
content_type: concept
55
weight: 40
6+
math: true
67
---
78

89
<!-- overview -->
@@ -317,6 +318,18 @@ kind: Pod
317318
...
318319
```
319320

321+
## Formulae and equations
322+
323+
You can use the Docsy support for [diagrams and formulae](https://www.docsy.dev/docs/adding-content/diagrams-and-formulae/#latex-support-with-katex).
324+
325+
For example: `\\(\frac{7}{9} \sqrt{K^8 s}\\)`, which renders as \\(\frac{7}{9} \sqrt{K^8 s}\\).
326+
327+
Prefer inline formulae where reasonable, but you can use a `math` block if that's likely to help readers.
328+
329+
Read the Docsy guide to find out what you need to change in your page to activate support;
330+
if you have problems, add `math: true` to the page [front matter](https://gohugo.io/content-management/front-matter/)
331+
(you can do this even if you think the automatic activation should be enough).
332+
320333
## Kubernetes.io word list
321334

322335
A list of Kubernetes-specific terms and words to be used consistently across the site.

layouts/partials/scripts.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@
1010
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" integrity="sha512-IX+bU+wShHqfqaMHLMrtwi4nK6W/Z+QdZoL4kPNtRxI2wCLyHPMAdl3a43Fv1Foqv4AP+aiW6hg1dcrTt3xc+Q==" crossorigin="anonymous"></script>
1111
{{- end }}
1212

13+
{{ $needKaTeX := or .Site.Params.katex.enable .Params.math .Params.chem -}}
14+
{{ if $needKaTeX -}}
15+
{{/* load stylesheet and scripts for KaTeX support */ -}}
16+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
17+
integrity="sha512-6VMVcy7XQNyarhVuiL50FzpgCFKsyTd6YO93aaQEyET+BNaWvj0IgKR86Bf6+AmWczxAcSnL+JGjo+iStgO1gQ==" crossorigin="anonymous">
18+
{{/* The loading of KaTeX is deferred to speed up page rendering */ -}}
19+
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
20+
integrity="sha512-b9IKj4LCNrtCPBhceRcoYOHWW/S2q9fpl7iAJlyxYpykRj1SKM7FE9+E0NEnJ8g8ni47LBr2GuX9qzg/xeuwzQ=="
21+
crossorigin="anonymous">
22+
</script>
23+
{{/* To automatically render math in text elements, include the auto-render extension: */ -}}
24+
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
25+
integrity="sha512-iWiuBS5nt6r60fCz26Nd0Zqe0nbk1ZTIQbl3Kv7kYsX+yKMUFHzjaH2+AnM6vp2Xs+gNmaBAVWJjSmuPw76Efg==" crossorigin="anonymous"
26+
{{ 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 }}>
27+
</script>
28+
{{ end -}}
29+
1330
{{ $jsBs := resources.Get "vendor/bootstrap/dist/js/bootstrap.bundle.js" -}}
1431
{{ $jsBase := resources.Get "js/base.js" }}
1532
{{ $jsAnchor := resources.Get "js/anchor.js" }}

0 commit comments

Comments
 (0)