mermaid and graphviz support#625
mermaid and graphviz support#625tinglou wants to merge 8 commits intoMacDownApp:masterfrom tinglou:master
Conversation
Graph VisualizationTwo graph visualization grammer are supported, mermaid and graphviz. Mermaid
mermaid has 3 diagram syntax. Flow Chartgraph TD;
A-->B;
A-->C;
B-->D;
C-->D;
Sequence DiagramsequenceDiagram
participant Alice
participant Bob
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts <br/>prevail...
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
Ganttgantt
title A Gantt Diagram
section Section
A task :a1, 2014-01-01, 30d
Another task :after a1 , 20d
section Another
Task in sec :2014-01-12 , 12d
anther task : 24d
Graphviz
Please refer to Graphviz website for details. Supported rendering engines,
Here are some samples. Hashmapdigraph G {
nodesep=.05;
rankdir=LR;
node [shape=record,width=.1,height=.1];
node0 [label = "<f0> |<f1> |<f2> |<f3> |<f4> |<f5> |<f6> | ", height=2.5];
node [width = 1.5];
node1 [label = "{<n> n14 | 719 |<p> }"];
node2 [label = "{<n> a1 | 805 |<p> }"];
node3 [label = "{<n> i9 | 718 |<p> }"];
node4 [label = "{<n> e5 | 989 |<p> }"];
node5 [label = "{<n> t20 | 959 |<p> }"] ;
node6 [label = "{<n> o15 | 794 |<p> }"] ;
node7 [label = "{<n> s19 | 659 |<p> }"] ;
node0:f0 -> node1:n;
node0:f1 -> node2:n;
node0:f2 -> node3:n;
node0:f5 -> node4:n;
node0:f6 -> node5:n;
node2:p -> node6:n;
node4:p -> node7:n;
}Process diagram with clustersdigraph G {
subgraph cluster0 {
node [style=filled,color=white];
style=filled;
color=lightgrey;
a0 -> a1 -> a2 -> a3;
label = "process #1";
}
subgraph cluster1 {
node [style=filled];
b0 -> b1 -> b2 -> b3;
label = "process #2";
color=blue
}
start -> a0;
start -> b0;
a1 -> b3;
b2 -> a3;
a3 -> a0;
a3 -> end;
b3 -> end;
start [shape=Mdiamond];
end [shape=Msquare];
} |
|
Above are output pdf and source markdown. |
|
Is it a good idea to overload the code block syntax? What happens if the user really wants to syntax highlight Mermaid and Graphviz source code? |
|
Could these be provided as plugins? Could I possibly write one myself? I'd personally like to be able to use Markdeep's ASCII art diagrams, and pasting the script tag in directly doesn't work (not to mention pulls in the rest of Markdeep, which I don't want). |
|
You could use a mermaidrender as code block syntax name so you can style highlight with mermaid and render it with mermaidrender. |
|
@loopingz Good suggestion, but I prefer |
|
Sure it is cleaner you are right :) |
|
I've taken the time to resolve the issue with conflicting files and also corrected another trouble area. Happy to provide updated patch if interested.. |
|
Please do @jeremykittel :) (Probably easiest if the maintainers merge this PR into a work-in-progress feature branch where you can apply your fixes to, then review the branch in total.) |
|
I would love this feature. Let me know if I can help. |
|
@ThadeuLuz Try to come up with a better syntax for the Mermaid and Graphviz block. I really dislike the current syntax, even the |
|
@uranusjr that means you won't ever consider merging it, and we should fork it ? |
|
@loopingz Honestly I’m still swinging on this issue. Ideally this should be done as a plug-in, but that requires some structural change in the parser. Ideally I should work on the parser, but life means I don’t really have the time in the foreseeable future. Ah hack, let’s just merge this. Resolve the conflicts, I’ll merge and do a pre-release before by the end of the month. I can always refactor this if I ever decide to develop MacDown 2.0 someday. p.s. Add yourself in the Credits.rtf file while you’re on this. |
|
Oh, and there should probably be some license files because we’ll vendor Mermaid and Graphviz right? Mermaid is MIT licensed so there should be a copy of its license inside the |
|
According to this article it should be enough to include their license text. The Graphviz code is included without modification (right?) so we fall into the “redistribute a program with an EPL component” category. But I need some first-hand sources to back this. |
|
Hi, The new PR is there : #865 |
|
awesome |
I don't see these two render options. How do I enable them? |
|
@Norfeldt It’s currently only available for testing release. |
|
@FranklinYu thank you very much. I can confirm that it is possible to render mermaid and graphviz. But the mermaid renders twice.. |
|
It's not so good now. |
|
@yixikkjkj Try 0.7.2d137 |



https://github.com/knsv/mermaid
http://www.graphviz.org/Home.php
Closes #785.