#117, Update KaTeX shortcode, add displayMode param

This commit is contained in:
Alex Shpak 2020-01-13 19:05:54 +01:00
parent b9f45270a0
commit 9fa444757a
2 changed files with 17 additions and 6 deletions

View file

@ -6,7 +6,7 @@ KaTeX shortcode let you render math typesetting in markdown document. See [KaTeX
{{< columns >}}
```latex
{{</* katex [class="text-center"] */>}}
{{</* katex [display] [class="text-center"] */>}}
x = \begin{cases}
a &\text{if } b \\
c &\text{if } d
@ -25,3 +25,13 @@ x = \begin{cases}
{{< /columns >}}
## Display Mode Example
Here is some inline example: {{< katex >}}\pi(x){{< /katex >}}, rendered in the same line. And below is `display` example, having `display: block`
{{< katex display >}}
x = \begin{cases}
a &\text{if } b \\
c &\text{if } d
\end{cases}
{{< /katex >}}
Text continues here.

View file

@ -7,7 +7,8 @@
{{ .Page.Scratch.Set "katex" true }}
{{ end }}
<p class="katex{{ with .Get "class" }} {{ . }}{{ end }}">
$$ {{- .Inner -}} $$
</p>
<span class="katex{{ with .Get "class" }} {{ . }}{{ end }}">
{{ if in .Params "display" }}\[{{ else }}\({{ end -}}
{{ $.Inner }}
{{- if in .Params "display" }}\]{{ else }}\){{ end }}
</span>