Skip to content
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

feature: add support for GLFM math blocks #987

Merged
merged 3 commits into from
Oct 16, 2022
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
16 changes: 16 additions & 0 deletions layouts/_default/_markup/render-codeblock-math.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* set default delimiters */}}
{{ $delimiter_left := "$$" }}
{{ $delimiter_right := "$$" }}

{{/* override delimiters if set in config file */}}
{{ with $.Page.Site.Params.katex.options.delimiters }}
{{ range first 1 ( where . "display" true ) }}
{{ $delimiter_left = index . "left" }}
{{ $delimiter_right = index . "right" }}
{{ end }}
{{end}}

{{/* output of equation */}}
<p>{{ $delimiter_left }}
{{ .Inner | safeHTML }}
{{ $delimiter_right }}</p>
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,22 @@ The following code sample produces an introductory text line followed by a formu

```tex
The probability of getting \\(k\\) heads when flipping \\(n\\) coins is:
$$\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}$$
$$
\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}$$
$$
\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) (requires hugo 0.93 or newer):
````markdown
```math
\tag*{(1)} P(E) = {n \choose k} p^k (1-p)^{n-k}
```
````

{{% 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.
Expand Down