Skip to content

Commit 5712c6d

Browse files
committed
Release 0.2.16
1 parent e32cbe3 commit 5712c6d

12 files changed

+321
-352
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mermaid",
3-
"version": "0.2.15",
3+
"version": "0.2.16",
44
"authors": [
55
66
],

dist/mermaid.full.js

+97-107
Large diffs are not rendered by default.

dist/mermaid.full.min.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mermaid.slim.js

+97-107
Large diffs are not rendered by default.

dist/mermaid.slim.min.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mermaid",
3-
"version": "0.2.15",
3+
"version": "0.2.16",
44
"description": "Markdownish syntax for generating flowcharts",
55
"main": "src/main.js",
66
"scripts": {

src/diagrams/flowchart/parser/flow.jison

+9-19
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ graphConfig
138138

139139
statements
140140
: statement spaceListNewline statements
141+
| statement statements
141142
| statement
142143
;
143144

@@ -157,27 +158,16 @@ spaceList
157158

158159
statement
159160
: commentStatement NEWLINE
160-
{$$='Comment';}
161-
| verticeStatement SEMI
162-
| verticeStatement NEWLINE
163-
| verticeStatement EOF
164-
| styleStatement SEMI
165-
| styleStatement NEWLINE
166-
| styleStatement EOF
167-
| linkStyleStatement SEMI
168-
| linkStyleStatement NEWLINE
169-
| linkStyleStatement EOF
170-
| classDefStatement SEMI
171-
| classDefStatement NEWLINE
172-
| classDefStatement EOF
173-
| classStatement SEMI
174-
| classStatement NEWLINE
175-
| classStatement EOF
176-
| clickStatement SEMI
177-
| clickStatement NEWLINE
178-
| clickStatement EOF
161+
| verticeStatement separator
162+
| styleStatement separator
163+
| linkStyleStatement separator
164+
| classDefStatement separator
165+
| classStatement separator
166+
| clickStatement separator
179167
;
180168

169+
separator: NEWLINE | SEMI | EOF ;
170+
181171
verticeStatement:
182172
vertex link vertex
183173
{ yy.addLink($1,$3,$2);$$ = 'oy'}

src/diagrams/flowchart/parser/flow.js

+70-73
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/diagrams/flowchart/parser/flow.spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ describe('when parsing ',function(){
6161
expect(edges[0].type).toBe('arrow');
6262
expect(edges[0].text).toBe('');
6363
});
64+
it('should handle statements ending without semicolon',function(){
65+
var res = flow.parser.parse('graph TD\nA-->B\nB-->C');
66+
67+
68+
var vert = flow.parser.yy.getVertices();
69+
var edges = flow.parser.yy.getEdges();
70+
71+
expect(vert['A'].id).toBe('A');
72+
expect(vert['B'].id).toBe('B');
73+
expect(edges.length).toBe(2);
74+
expect(edges[1].start).toBe('B');
75+
expect(edges[1].end).toBe('C');
76+
expect(edges[0].type).toBe('arrow');
77+
expect(edges[0].text).toBe('');
78+
});
6479

6580
it('should handle a comments',function(){
6681
var res = flow.parser.parse('graph TD;\n%% CComment\n A-->B;');

src/diagrams/sequenceDiagram/sequenceRenderer.js

+18-31
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ sq.yy = require('./sequenceDb');
1313
* @param description The text in the box
1414
*/
1515
var drawNote = function(elem, startX, verticalPos, msg){
16-
var insertLinebreaks = function (d) {
17-
var el = d3.select(this);
18-
var words = d.split(' ');
19-
el.text('');
20-
21-
for (var i = 0; i < words.length; i++) {
22-
var tspan = el.append('tspan').text(words[i]);
23-
if (i > 0)
24-
tspan.attr('x', 0).attr('dy', '15');
25-
}
26-
};
27-
2816
var g = elem.append("g");
2917
var rectElem = g.append("rect")
3018
.attr("x", startX + 25)
@@ -41,20 +29,32 @@ var drawNote = function(elem, startX, verticalPos, msg){
4129
.style("text-anchor", "start");
4230
msg.message.split('<br>').forEach(function(rowText){
4331
textElem.append("tspan")
44-
.attr("x", startX + 35)
32+
.attr("x", startX + 35 )
4533
.attr("dy", '1em')
4634
.text(rowText);
4735
});
4836

4937
console.log('textElem.height');
5038
console.log(textElem[0][0].getBBox());
5139
rectElem.attr('height',textElem[0][0].getBBox().height+20);
52-
//console.log(textElem.getBBox().height);
5340

54-
//.text(msg.message + '\n' + msg.message)
41+
return verticalPos + textElem[0][0].getBBox().height - 10;
42+
};
5543

5644

57-
return verticalPos + textElem[0][0].getBBox().height - 10;
45+
/**
46+
* Setup arrow head and define the marker. The result is appended to the svg.
47+
*/
48+
var insertArrowHead = function(elem){
49+
elem.append("defs").append("marker")
50+
.attr("id", "arrowhead")
51+
.attr("refX", 5) /*must be smarter way to calculate shift*/
52+
.attr("refY", 2)
53+
.attr("markerWidth", 6)
54+
.attr("markerHeight", 4)
55+
.attr("orient", "auto")
56+
.append("path")
57+
.attr("d", "M 0,0 V 4 L6,2 Z"); //this is actual shape for arrowhead
5858
};
5959

6060
/**
@@ -73,6 +73,7 @@ module.exports.draw = function (text, id) {
7373
var height = 65;
7474
var yStartMargin = 10;
7575
var diagram = d3.select('#'+id);
76+
7677
/**
7778
* Draws an actor in the diagram with the attaced line
7879
* @param center - The center of the the actor
@@ -106,21 +107,6 @@ module.exports.draw = function (text, id) {
106107
;
107108
};
108109

109-
/**
110-
* Setup arrow head and define the marker. The result is appended to the svg.
111-
*/
112-
var insertArrowHead = function(elem){
113-
elem.append("defs").append("marker")
114-
.attr("id", "arrowhead")
115-
.attr("refX", 5) /*must be smarter way to calculate shift*/
116-
.attr("refY", 2)
117-
.attr("markerWidth", 6)
118-
.attr("markerHeight", 4)
119-
.attr("orient", "auto")
120-
.append("path")
121-
.attr("d", "M 0,0 V 4 L6,2 Z"); //this is actual shape for arrowhead
122-
};
123-
124110
var drawMessage = function(elem, startx, stopx, verticalPos, txtCenter, msg){
125111
var g = elem.append("g");
126112
//Make an SVG Container
@@ -220,4 +206,5 @@ module.exports.draw = function (text, id) {
220206

221207
diagram.attr("height", verticalPos + 40);
222208
diagram.attr("width", maxX );
209+
diagram.attr("transform", 'translate(150 0)' );
223210
};

test/web.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ <h1>Sequence diagrams (experimental)</h1>
5858
<div class="mermaid">
5959
sequenceDiagram
6060
Alice->Bob: Hello Bob, how are you?
61-
Note right of Bob: Bob thinks about <br/> things <br/> to think about
61+
Note right of Alice: Bob thinks about <br/> things <br/> to think about
6262
Bob-->Alice: I am good thanks!
6363
Bob-->John the Long: How about you John?
6464
Bob-->Alice: Checking with John...

test/web_style.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h3>CSS in the page head:</h3>
5757
</pre>
5858
<h3>Graph definition</h3>
5959
<pre>
60-
graph TD;
60+
graph LR;
6161

6262
noc[No class&lt;br />using default];
6363
cyr2((Class node-cyr-undefined&lt;br /&gt;is undefined, using default));
@@ -98,7 +98,7 @@ <h3>Graph definition</h3>
9898
</pre>
9999

100100
<div class="mermaid">
101-
graph TD;
101+
graph LR;
102102

103103
noc[No class<br />using default];
104104
cyr2((Class node-cyr-undefined<br />is undefined, using default));

0 commit comments

Comments
 (0)