From 2d994e6ac61e9e3ec949f7083e24231969b1a620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Mon, 31 Oct 2022 15:27:31 +0100 Subject: [PATCH] math: allow passing of parameters with codefence syntax #363 --- exampleSite/content/shortcodes/math.en.md | 17 ++++++++++++----- exampleSite/content/shortcodes/mermaid.en.md | 9 +++++++++ .../_default/_markup/render-codeblock-math.html | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/exampleSite/content/shortcodes/math.en.md b/exampleSite/content/shortcodes/math.en.md index 2ed9eceeca..c3174bce62 100644 --- a/exampleSite/content/shortcodes/math.en.md +++ b/exampleSite/content/shortcodes/math.en.md @@ -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 -{{}} +{{}} $$\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)$$ {{}} ```` @@ -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)$$ +``` diff --git a/exampleSite/content/shortcodes/mermaid.en.md b/exampleSite/content/shortcodes/mermaid.en.md index be77ba2071..3725074740 100644 --- a/exampleSite/content/shortcodes/mermaid.en.md +++ b/exampleSite/content/shortcodes/mermaid.en.md @@ -270,3 +270,12 @@ stateDiagram-v2 locked --> closed: Unlock closed --> open: Open ```` + + + + +```mermaid { align="left" } +graph LR; + If --> Then + Then --> Else +``` diff --git a/layouts/_default/_markup/render-codeblock-math.html b/layouts/_default/_markup/render-codeblock-math.html index b0f9bc1663..29d2a597e1 100644 --- a/layouts/_default/_markup/render-codeblock-math.html +++ b/layouts/_default/_markup/render-codeblock-math.html @@ -1,4 +1,5 @@ {{- partial "shortcodes/math.html" (dict "context" . "content" .Inner + "align" (index .Attributes "align") ) }} \ No newline at end of file