Skip to content

Commit

Permalink
alex-shpak#117, Update KaTeX shortcode, add displayMode param
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-shpak committed Jan 13, 2020
1 parent b9f4527 commit 9fa4447
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 12 additions & 2 deletions exampleSite/content/docs/shortcodes/katex.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

KaTeX shortcode let you render math typesetting in markdown document. See [KaTeX](https://katex.org/)

## Example
## Example
{{< columns >}}

```latex
{{</* katex [class="text-center"] */>}}
{{</* katex [display] [class="text-center"] */>}}
x = \begin{cases}
a &\text{if } b \\
c &\text{if } d
Expand All @@ -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.
9 changes: 5 additions & 4 deletions layouts/shortcodes/katex.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 9fa4447

Please sign in to comment.