Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
oru-sapelem committed Jun 27, 2019
1 parent 62a1f15 commit 60d18ef
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 5 deletions.
74 changes: 73 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,74 @@
# md_mermaid
mermaid extension to add support for mermaid graph inside markdown file
mermaid extension for Python-Markdown to add support for mermaid graph inside markdown file

## Installation

* pip (only python version >=3.x) :

~~~shell
pip install markdown
pip install md-mermaid
~~~

## Usage

In your python script :

~~~python
import markdown

text = """
# Title
Some text.
​~~~mermaid
graph TB
A --> B
B --> C
​~~~
Some other text.
​~~~mermaid
graph TB
D --> E
E --> F
​~~~
"""

html = markdown.markdown(text, extensions=['md_mermaid'])

print(html)
~~~

Output will result in :

~~~html
<h1>Title</h1>
<p>Some text.</p>
<div class="mermaid">
graph TB
A --> B
B --> C
</div>

<p>Some other text.</p>
<div class="mermaid">
graph TB
D --> E
E --> F
</div>

<script>mermaid.initialize({startOnLoad:true});</script>

~~~

The `<script>...</script>` line appears only once even if there are several graphs in the file.

> Note that the extension name have a '_' not a '-'.
> Attention : don't forget to include in your output html project the two following mermaid files :
>
> * mermaid.css (optional, can be customised)
> * mermaid.min.js (can be download here [here](https://unpkg.com/[email protected]/dist/))
5 changes: 2 additions & 3 deletions md_mermaid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Original code Copyright 2018-2020 [Olivier Ruelle].
License: [BSD](http://www.opensource.org/licenses/bsd-license.php)
License: GNU GPLv3
"""

Expand Down Expand Up @@ -54,7 +54,7 @@ def run(self, lines):
elif in_mermaid_code:
new_lines.append(line.strip())
else:

new_lines.append(line)

old_line = line
Expand All @@ -79,4 +79,3 @@ def extendMarkdown(self, md, md_globals):

def makeExtension(**kwargs): # pragma: no cover
return MermaidExtension(**kwargs)

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='md_mermaid',
version='0.1.1',
version='0.1.0',
author='Olivier Ruelle',
author_email='[email protected]',
description='Python-Markdown extension to add support for mermaid graph inside markdown file.',
Expand Down

0 comments on commit 60d18ef

Please sign in to comment.