Skip to content

Commit 327e3dd

Browse files
committed
Add Python sample code
1 parent 2532f1f commit 327e3dd

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ site/
1616
node_modules
1717
package.json
1818
package-lock.json
19+
20+
# this project
21+
sample_code.html
22+

sample_code.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
3+
import markdown
4+
from markdown_mermaid_cli import MermaidExtension
5+
6+
markdown_text = """
7+
# Sample Markdown with Mermaid Diagram
8+
9+
## Mermaid Diagram
10+
11+
```mermaid format=svg width=500 alt="sequenceDiagram" theme="forest" backgroundColor="#dcdcdc"
12+
sequenceDiagram
13+
participant Alice
14+
participant Bob
15+
Bob->>Alice: Hi Alice
16+
Alice->>Bob: Hi Bob
17+
```
18+
"""
19+
20+
html_output = markdown.markdown(markdown_text, extensions=[MermaidExtension()])
21+
22+
with open(os.path.splitext(__file__)[0] + '.html', 'w') as f:
23+
f.write(html_output)

0 commit comments

Comments
 (0)