Skip to content

Commit

Permalink
feature: add support for GLFM math blocks
Browse files Browse the repository at this point in the history
This add supports for GLFM's math blocks [1] using hugo's Markdown
render hooks [2].

[1]: https://docs.gitlab.com/ee/user/markdown.html#math
[2]: https://gohugo.io/templates/render-hooks/#render-hooks-for-code-blocks

Signed-off-by: Stephan Lachnit <stephanlachnit@debian.org>
  • Loading branch information
stephanlachnit committed Apr 26, 2022
1 parent f97f4f8 commit 51ed515
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions layouts/_default/_markup/render-codeblock-math.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>```math
{{ .Inner | safeHTML }}
```</p>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ $$\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}$$
The probability of getting \\(k\\) heads when flipping \\(n\\) coins is:
$$\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}$$

You can also use [GLFM's math blocks](https://docs.gitlab.com/ee/user/markdown.html#math):
````markdown
```math
E = m c^2
```
````

{{% alert title="Tip" %}}
This [wiki page](https://en.wikibooks.org/wiki/LaTeX/Mathematics) provides in-depth information about typesetting mathematical formulae using the \\(\LaTeX\\) typesetting system.
{{% /alert %}}
Expand Down Expand Up @@ -86,6 +93,10 @@ errorColor = "#CD5C5C"
left = "\\["
right = '\\]'
display = true
[[params.katex.options.delimiters]]
left = "```math"
right = '```'
display = true
```

For a complete list of options and their detailed description, have a look at the documentation of \\({\KaTeX}'s\\) [Rendering API options](https://katex.org/docs/autorender.html#api) and of \\({\KaTeX}'s\\) [configuration options](https://katex.org/docs/options.html).
Expand Down

0 comments on commit 51ed515

Please sign in to comment.