mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 01:09:42 +02:00
Use monaco-mermaid for syntax highlighting and many syntax highlighting improvements
This commit is contained in:
@@ -10,7 +10,7 @@ It can also accomodate different arrow types, multi directional arrows, and link
|
||||
Node
|
||||
### A node (default)
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id
|
||||
```
|
||||
@@ -28,7 +28,7 @@ It is also possible to set text in the box that differs from the id. If this is
|
||||
found for the node that will be used. Also if you define edges for the node later on, you can omit text definitions. The
|
||||
one previously defined will be used when rendering the box.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1[This is the text in the box]
|
||||
```
|
||||
@@ -43,7 +43,7 @@ This statement declares the direction of the Flowchart.
|
||||
|
||||
This declares the flowchart is oriented from top to bottom (`TD` or `TB`).
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TD
|
||||
Start --> Stop
|
||||
```
|
||||
@@ -54,7 +54,7 @@ flowchart TD
|
||||
|
||||
This declares the flowchart is oriented from left to right (`LR`).
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
Start --> Stop
|
||||
```
|
||||
@@ -77,7 +77,7 @@ Possible FlowChart orientations are:
|
||||
|
||||
### A node with round edges
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1(This is the text in the box)
|
||||
```
|
||||
@@ -88,7 +88,7 @@ flowchart LR
|
||||
|
||||
### A stadium-shaped node
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1([This is the text in the box])
|
||||
```
|
||||
@@ -99,7 +99,7 @@ flowchart LR
|
||||
|
||||
### A node in a subroutine shape
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1[[This is the text in the box]]
|
||||
```
|
||||
@@ -110,7 +110,7 @@ flowchart LR
|
||||
|
||||
### A node in a cylindrical shape
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1[(Database)]
|
||||
```
|
||||
@@ -121,7 +121,7 @@ flowchart LR
|
||||
|
||||
### A node in the form of a circle
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1((This is the text in the circle))
|
||||
```
|
||||
@@ -132,7 +132,7 @@ flowchart LR
|
||||
|
||||
### A node in an asymmetric shape
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1>This is the text in the box]
|
||||
```
|
||||
@@ -144,7 +144,7 @@ Currently only the shape above is possible and not its mirror. *This might chang
|
||||
|
||||
### A node (rhombus)
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1{This is the text in the box}
|
||||
```
|
||||
@@ -154,7 +154,7 @@ flowchart LR
|
||||
```
|
||||
|
||||
### A hexagon node
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1{{This is the text in the box}}
|
||||
```
|
||||
@@ -166,7 +166,7 @@ flowchart LR
|
||||
|
||||
### Parallelogram
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TD
|
||||
id1[/This is the text in the box/]
|
||||
```
|
||||
@@ -177,7 +177,7 @@ flowchart TD
|
||||
|
||||
### Parallelogram alt
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TD
|
||||
id1[\This is the text in the box\]
|
||||
```
|
||||
@@ -188,7 +188,7 @@ flowchart TD
|
||||
|
||||
### Trapezoid
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TD
|
||||
A[/Christmas\]
|
||||
```
|
||||
@@ -198,7 +198,7 @@ flowchart TD
|
||||
```
|
||||
### Trapezoid alt
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TD
|
||||
B[\Go shopping/]
|
||||
```
|
||||
@@ -213,7 +213,7 @@ Nodes can be connected with links/edges. It is possible to have different types
|
||||
|
||||
### A link with arrow head
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A-->B
|
||||
```
|
||||
@@ -224,7 +224,7 @@ flowchart LR
|
||||
|
||||
### An open link
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A --- B
|
||||
```
|
||||
@@ -235,7 +235,7 @@ flowchart LR
|
||||
|
||||
### Text on links
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A-- This is the text! ---B
|
||||
```
|
||||
@@ -246,7 +246,7 @@ flowchart LR
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A---|This is the text|B
|
||||
```
|
||||
@@ -257,7 +257,7 @@ flowchart LR
|
||||
|
||||
### A link with arrow head and text
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A-->|text|B
|
||||
```
|
||||
@@ -268,7 +268,7 @@ flowchart LR
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A-- text -->B
|
||||
```
|
||||
@@ -279,7 +279,7 @@ flowchart LR
|
||||
|
||||
### Dotted link
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR;
|
||||
A-.->B;
|
||||
```
|
||||
@@ -290,7 +290,7 @@ flowchart LR;
|
||||
|
||||
### Dotted link with text
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A-. text .-> B
|
||||
```
|
||||
@@ -301,7 +301,7 @@ flowchart LR
|
||||
|
||||
### Thick link
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A ==> B
|
||||
```
|
||||
@@ -312,7 +312,7 @@ flowchart LR
|
||||
|
||||
### Thick link with text
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A == text ==> B
|
||||
```
|
||||
@@ -324,7 +324,7 @@ flowchart LR
|
||||
### Chaining of links
|
||||
|
||||
It is possible declare many links in the same line as per below:
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A -- text --> B -- text2 --> C
|
||||
```
|
||||
@@ -334,7 +334,7 @@ flowchart LR
|
||||
```
|
||||
|
||||
It is also possible to declare multiple nodes links in the same line as per below:
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
a --> b & c--> d
|
||||
```
|
||||
@@ -344,7 +344,7 @@ flowchart LR
|
||||
```
|
||||
|
||||
You can then describe dependencies in a very expressive way. Like the one-liner below:
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TB
|
||||
A & B--> C & D
|
||||
```
|
||||
@@ -356,7 +356,7 @@ If you describe the same diagram using the the basic syntax, it will take four l
|
||||
word of warning, one could go overboard with this making the flowchart harder to read in
|
||||
markdown form. The Swedish word `lagom` comes to mind. It means, not too much and not too little.
|
||||
This goes for expressive syntaxes as well.
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TB
|
||||
A --> C
|
||||
A --> D
|
||||
@@ -368,7 +368,7 @@ flowchart TB
|
||||
|
||||
There are new types of arrows supported as per below:
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A --o B
|
||||
B --x C
|
||||
@@ -385,7 +385,7 @@ flowchart LR
|
||||
|
||||
There is the possibility to use multidirectional arrows.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A o--o B
|
||||
B <--> C
|
||||
@@ -410,7 +410,7 @@ than the others by adding extra dashes in the link definition.
|
||||
In the following example, two extra dashes are added in the link from node _B_
|
||||
to node _E_, so that it spans two more ranks than regular links:
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TD
|
||||
A[Start] --> B{Is it?};
|
||||
B -->|Yes| C[OK];
|
||||
@@ -435,7 +435,7 @@ When the link label is written in the middle of the link, the extra dashes must
|
||||
be added on the right side of the link. The following example is equivalent to
|
||||
the previous one:
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TD
|
||||
A[Start] --> B{Is it?};
|
||||
B -- Yes --> C[OK];
|
||||
@@ -469,7 +469,7 @@ as summed up in the following table:
|
||||
|
||||
It is possible to put text within quotes in order to render more troublesome characters. As in the example below:
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1["This is the (text) in the box"]
|
||||
```
|
||||
@@ -482,7 +482,7 @@ flowchart LR
|
||||
|
||||
It is possible to escape characters using the syntax exemplified here.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A["A double quote:#quot;"] -->B["A dec char:#9829;"]
|
||||
```
|
||||
@@ -503,7 +503,7 @@ end
|
||||
|
||||
An example below:
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TB
|
||||
c1-->a2
|
||||
subgraph one
|
||||
@@ -532,7 +532,7 @@ flowchart TB
|
||||
|
||||
You can also set an explicit id for the subgraph.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TB
|
||||
c1-->a2
|
||||
subgraph ide1 [one]
|
||||
@@ -551,7 +551,7 @@ flowchart TB
|
||||
|
||||
With the graphtype flowcharts it is also possible to set edges to and from subgraphs as in the flowchart below.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TB
|
||||
c1-->a2
|
||||
subgraph one
|
||||
@@ -589,7 +589,7 @@ flowchart TB
|
||||
|
||||
With the graphtype flowcharts you can use the direction statement to set the direction which the subgraph will render like in this example.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
subgraph TOP
|
||||
direction TB
|
||||
@@ -646,7 +646,7 @@ Examples of tooltip usage below:
|
||||
</script>
|
||||
```
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR;
|
||||
A-->B;
|
||||
B-->C;
|
||||
@@ -674,7 +674,7 @@ flowchart LR
|
||||
?> Due to limitations with how Docsify handles JavaScript callback functions, an alternate working demo for the above code can be viewed at [this jsfiddle](https://jsfiddle.net/s37cjoau/3/).
|
||||
|
||||
Links are opened in the same browser tab/window by default. It is possible to change this by adding a link target to the click definition (`_self`, `_blank`, `_parent` and `_top` are supported):
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR;
|
||||
A-->B;
|
||||
B-->C;
|
||||
@@ -735,7 +735,7 @@ Beginners tip, a full example using interactive links in a html context:
|
||||
|
||||
Comments can be entered within a flow diagram, which will be ignored by the parser. Comments need to be on their own line, and must be prefaced with `%%` (double percent signs). Any text after the start of the comment to the next newline will be treated as a comment, including any flow syntax
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
%% this is a comment A -- text --> B{node}
|
||||
A -- text --> B -- text2 --> C
|
||||
@@ -750,7 +750,7 @@ have no ids in the same way as nodes, some other way of deciding what style the
|
||||
Instead of ids, the order number of when the link was defined in the graph is used. In the example below the style
|
||||
defined in the linkStyle statement will belong to the fourth link in the graph:
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;
|
||||
```
|
||||
|
||||
@@ -759,7 +759,7 @@ linkStyle 3 stroke:#ff3,stroke-width:4px,color:red;
|
||||
|
||||
It is possible to apply specific styles such as a thicker border or a different background color to a node.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
id1(Start)-->id2(Stop)
|
||||
style id1 fill:#f9f,stroke:#333,stroke-width:4px
|
||||
@@ -799,7 +799,7 @@ It is also possible to attach a class to a list of nodes in one statement:
|
||||
|
||||
A shorter form of adding a class is to attach the classname to the node using the `:::`operator as per below:
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A:::someclass --> B
|
||||
classDef someclass fill:#f96;
|
||||
@@ -830,7 +830,7 @@ below:
|
||||
|
||||
**Example definition**
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR;
|
||||
A-->B[AAA<span>BBB</span>];
|
||||
B-->D;
|
||||
@@ -859,7 +859,7 @@ It is possible to add icons from fontawesome.
|
||||
|
||||
The icons are accessed via the syntax fa:#icon class name#.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart TD
|
||||
B["fa:fa-twitter for peace"]
|
||||
B-->C[fa:fa-ban forbidden]
|
||||
@@ -883,7 +883,7 @@ flowchart TD
|
||||
|
||||
Below is the new declaration of the graph edges which is also valid along with the old declaration of the graph edges.
|
||||
|
||||
```
|
||||
```mermaid-code
|
||||
flowchart LR
|
||||
A[Hard edge] -->|Link text| B(Round edge)
|
||||
B --> C{Decision}
|
||||
|
Reference in New Issue
Block a user