Mermaid diagrams: allow passing of parameters with codefence syntax

This commit is contained in:
Andreas Deininger 2022-10-31 11:29:05 +01:00
parent 114e97f1f9
commit 5745256519
2 changed files with 7 additions and 4 deletions

View file

@ -5,7 +5,7 @@ title = "Mermaid"
The `mermaid` shortcode generates diagrams and flowcharts from text, in a similar manner as Markdown using the [Mermaid](https://mermaidjs.github.io/) library. The `mermaid` shortcode generates diagrams and flowcharts from text, in a similar manner as Markdown using the [Mermaid](https://mermaidjs.github.io/) library.
{{< mermaid >}} {{< mermaid align="center" >}}
graph LR; graph LR;
If --> Then If --> Then
Then --> Else Then --> Else
@ -33,7 +33,7 @@ To use codefence syntax you have to turn off `guessSyntax` for the `markup.highl
{{% tab name="codefence" %}} {{% tab name="codefence" %}}
````md ````md
```mermaid ```mermaid { align="center" }
graph LR; graph LR;
If --> Then If --> Then
Then --> Else Then --> Else
@ -44,7 +44,7 @@ graph LR;
{{% tab name="shortcode" %}} {{% tab name="shortcode" %}}
````go ````go
{{</* mermaid */>}} {{</* mermaid align="center" */>}}
graph LR; graph LR;
If --> Then If --> Then
Then --> Else Then --> Else
@ -58,6 +58,7 @@ graph LR;
{{ partial "shortcodes/mermaid.html" (dict {{ partial "shortcodes/mermaid.html" (dict
"context" . "context" .
"content" "graph LR;\nIf --> Then\nThen --> Else" "content" "graph LR;\nIf --> Then\nThen --> Else"
"align" "center"
)}} )}}
```` ````
@ -69,7 +70,7 @@ The generated graphs can be be panned by dragging them and zoomed by using the m
### Parameter ### Parameter
Parameter are only supported when using shortcode or partial syntax. Defaults are used when using codefence syntax. Passing parameters is supported for each available syntax (codefence, shortcode and partial).
| Name | Default | Notes | | Name | Default | Notes |
|:----------------------|:-----------------|:------------| |:----------------------|:-----------------|:------------|

View file

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