math: allow passing of parameters with codefence syntax #363

This commit is contained in:
Sören Weber 2022-10-31 15:27:31 +01:00
parent b985b99468
commit 2d994e6ac6
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
3 changed files with 22 additions and 5 deletions

View file

@ -5,7 +5,7 @@ title = "Math"
The `math` shortcode generates beautiful formatted math and chemical formulae using the [MathJax](https://mathjax.org/) library.
{{< math >}}
{{< math align="center" >}}
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
{{< /math >}}
@ -27,7 +27,7 @@ To use codefence syntax you have to turn off `guessSyntax` for the `markup.highl
{{% tab name="codefence" %}}
````md
```math
```math { align="center" }
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
```
````
@ -36,7 +36,7 @@ $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \
{{% tab name="shortcode" %}}
````go
{{</* math */>}}
{{</* math align="center" */>}}
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
{{</* /math */>}}
````
@ -48,6 +48,7 @@ $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \
{{ partial "shortcodes/math.html" (dict
"context" .
"content" "$$left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$"
"align" "center"
)}}
````
@ -57,8 +58,6 @@ $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \
### Parameter
Parameter are only supported when using shortcode or partial syntax. Defaults are used when using codefence syntax.
| Name | Default | Notes |
|:----------------------|:-----------------|:------------|
| **align** | `center` | Allowed values are `left`, `center` or `right`. |
@ -149,3 +148,11 @@ $$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
{{< math >}}
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
{{< /math >}}
```math { align="left" }
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
```

View file

@ -270,3 +270,12 @@ stateDiagram-v2
locked --> closed: Unlock
closed --> open: Open
````
```mermaid { align="left" }
graph LR;
If --> Then
Then --> Else
```

View file

@ -1,4 +1,5 @@
{{- partial "shortcodes/math.html" (dict
"context" .
"content" .Inner
"align" (index .Attributes "align")
) }}