Skip to content

Commit 2088fc6

Browse files
committed
stage
1 parent 37f7505 commit 2088fc6

File tree

10 files changed

+86
-36
lines changed

10 files changed

+86
-36
lines changed

docs/_docset.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ toc:
8080
- file: conditionals.md
8181
- file: dropdowns.md
8282
- file: definition-lists.md
83+
- file: diagrams.md
8384
- file: example_blocks.md
8485
- file: file_inclusion.md
8586
- file: frontmatter.md

docs/syntax/diagrams.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Diagrams
2+
3+
You can embedd diagrams using [mermaid.js](https://mermaid.js.org)
4+
5+
## Flowcharts
6+
7+
:::::{tab-set}
8+
9+
::::{tab-item} Output
10+
11+
:::{mermaid}
12+
flowchart LR
13+
A[Jupyter Notebook] --> C
14+
B[MyST Markdown] --> C
15+
C(mystmd) --> D{AST}
16+
D <--> E[LaTeX]
17+
E --> F[PDF]
18+
D --> G[Word]
19+
D --> H[React]
20+
D --> I[HTML]
21+
D <--> J[JATS]
22+
:::
23+
24+
::::
25+
26+
::::{tab-item} Markdown
27+
```markdown
28+
:::{mermaid}
29+
flowchart LR
30+
A[Jupyter Notebook] --> C
31+
B[MyST Markdown] --> C
32+
C(mystmd) --> D{AST}
33+
D <--> E[LaTeX]
34+
E --> F[PDF]
35+
D --> G[Word]
36+
D --> H[React]
37+
D --> I[HTML]
38+
D <--> J[JATS]
39+
:::
40+
```
41+
::::
42+
43+
:::::
44+
45+
46+
47+
```mermaid
48+
flowchart LR
49+
A[Jupyter Notebook] --> C
50+
B[MyST Markdown] --> C
51+
C(mystmd) --> D{AST}
52+
D <--> E[LaTeX]
53+
E --> F[PDF]
54+
D --> G[Word]
55+
D --> H[React]
56+
D --> I[HTML]
57+
D <--> J[JATS]
58+
```
59+

src/Elastic.Markdown/Myst/CodeBlocks/EnhancedCodeBlockHtmlRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private static void RenderCodeBlockLines(HtmlRenderer renderer, EnhancedCodeBloc
4848
if (indent >= commonIndent)
4949
slice.Start += commonIndent;
5050

51-
if (!hasCode)
51+
if (!hasCode && block.Language != "mermaid")
5252
{
5353
_ = renderer.Write($"<code class=\"language-{block.Language}\">");
5454
hasCode = true;

src/Elastic.Markdown/Myst/CodeBlocks/SupportedLanguages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static class CodeBlock
2727
{ "javascript", "js, jsx" }, // JavaScript
2828
{ "json", "jsonc" }, // JSON
2929
{ "kotlin", "kt" }, // Kotlin
30+
{ "mermaid", ""},
3031
{ "markdown", "md, mkdown, mkd" }, // Markdown
3132
{ "nginx", "nginxconf" }, // Nginx
3233
{ "php", "" }, // PHP

src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public DirectiveBlockParser()
4646
{ "grid", 26 },
4747
{ "grid-item-card", 26 },
4848
{ "card", 25 },
49-
{ "mermaid", 20 },
5049
{ "aside", 4 },
5150
{ "margin", 4 },
5251
{ "sidebar", 4 },
Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
@inherits RazorSlice<CodeViewModel>
2-
<div class="[email protected] notranslate">
3-
<div class="highlight">
4-
@if (!string.IsNullOrEmpty(Model.Caption))
5-
{
6-
<div class="code-block-caption">
7-
<span class="caption-text">@Model.Caption</span>
8-
<a class="headerlink" href="@Model.CrossReferenceName" title="Link to this code">¶</a>
9-
</div>
10-
}
11-
<pre>@if (!string.IsNullOrEmpty(Model.ApiCallHeader)) { <code class="language-apiheader">@Model.ApiCallHeader</code> }[CONTENT]</pre>
2+
@if (Model.Language == "mermaid")
3+
{
4+
<pre class="mermaid">
5+
[CONTENT]
6+
</pre>
7+
}
8+
else {
9+
<div class="[email protected] notranslate">
10+
<div class="highlight">
11+
@if (!string.IsNullOrEmpty(Model.Caption))
12+
{
13+
<div class="code-block-caption">
14+
<span class="caption-text">@Model.Caption</span>
15+
<a class="headerlink" href="@Model.CrossReferenceName" title="Link to this code"></a>
16+
</div>
17+
}
18+
<pre>@if (!string.IsNullOrEmpty(Model.ApiCallHeader)) { <code class="language-apiheader">@Model.ApiCallHeader</code> }[CONTENT]</pre>
19+
</div>
1220
</div>
13-
</div>
21+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@inherits RazorSlice<MermaidViewModel>
2-
<div class="mermaid">
2+
<pre class="mermaid">
33
[CONTENT]
4-
</div>
4+
</pre>

src/Elastic.Markdown/Slices/Layout/_Footer.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@
3434
</footer>
3535

3636
<script src="@Model.Static("main.js")"></script>
37+
<script src="https://unpkg.com/[email protected]/dist/mermaid.min.js"></script>
38+
<script>mermaid.initialize({startOnLoad:true});</script>

src/Elastic.Markdown/Slices/Layout/_Scripts.cshtml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Elastic.Markdown/Slices/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@
8080
</div>
8181
</aside>
8282
}
83+
<script>mermaid.initialize({startOnLoad:true});</script>
8384
</body>
8485
</html>

0 commit comments

Comments
 (0)