mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
Merge pull request #56 from vijay40/master
Improves readablity discussed in issue #38
This commit is contained in:
@@ -168,18 +168,30 @@ verticeStatement:
|
||||
|
||||
vertex: alphaNum SQS text SQE
|
||||
{$$ = $1;yy.addVertex($1,$3,'square');}
|
||||
| alphaNum SQS text SQE SPACE
|
||||
{$$ = $1;yy.addVertex($1,$3,'square');}
|
||||
| alphaNum PS PS text PE PE
|
||||
{$$ = $1;yy.addVertex($1,$4,'circle');}
|
||||
| alphaNum PS PS text PE PE SPACE
|
||||
{$$ = $1;yy.addVertex($1,$4,'circle');}
|
||||
| alphaNum PS text PE
|
||||
{$$ = $1;yy.addVertex($1,$3,'round');}
|
||||
| alphaNum PS text PE SPACE
|
||||
{$$ = $1;yy.addVertex($1,$3,'round');}
|
||||
| alphaNum DIAMOND_START text DIAMOND_STOP
|
||||
{$$ = $1;yy.addVertex($1,$3,'diamond');}
|
||||
| alphaNum DIAMOND_START text DIAMOND_STOP SPACE
|
||||
{$$ = $1;yy.addVertex($1,$3,'diamond');}
|
||||
| alphaNum TAGEND text SQE
|
||||
{$$ = $1;yy.addVertex($1,$3,'odd');}
|
||||
| alphaNum TAGEND text SQE SPACE
|
||||
{$$ = $1;yy.addVertex($1,$3,'odd');}
|
||||
| alphaNum TAGSTART text TAGEND
|
||||
{$$ = $1;yy.addVertex($1,$3,'diamond');}
|
||||
| alphaNum
|
||||
{$$ = $1;yy.addVertex($1);}
|
||||
| alphaNum SPACE
|
||||
{$$ = $1;yy.addVertex($1);}
|
||||
;
|
||||
|
||||
alphaNum
|
||||
@@ -218,9 +230,13 @@ alphaNumToken
|
||||
;
|
||||
|
||||
link: linkStatement arrowText
|
||||
{$1.text = $2;$$ = $1;}
|
||||
| linkStatement arrowText SPACE
|
||||
{$1.text = $2;$$ = $1;}
|
||||
| linkStatement
|
||||
{$$ = $1;}
|
||||
| linkStatement SPACE
|
||||
{$$ = $1;}
|
||||
;
|
||||
|
||||
linkStatement: ARROW_POINT
|
||||
|
File diff suppressed because one or more lines are too long
@@ -30,6 +30,22 @@ describe('when parsing ',function(){
|
||||
expect(edges[0].text).toBe('');
|
||||
});
|
||||
|
||||
it('should handle a nodes and edges and a space between link and node',function(){
|
||||
var res = flow.parser.parse('graph TD;A --> B;');
|
||||
|
||||
|
||||
var vert = flow.parser.yy.getVertices();
|
||||
var edges = flow.parser.yy.getEdges();
|
||||
|
||||
expect(vert['A'].id).toBe('A');
|
||||
expect(vert['B'].id).toBe('B');
|
||||
expect(edges.length).toBe(1);
|
||||
expect(edges[0].start).toBe('A');
|
||||
expect(edges[0].end).toBe('B');
|
||||
expect(edges[0].type).toBe('arrow');
|
||||
expect(edges[0].text).toBe('');
|
||||
});
|
||||
|
||||
it('should handle a comments',function(){
|
||||
var res = flow.parser.parse('graph TD;\n%% CComment\n A-->B;');
|
||||
|
||||
@@ -134,6 +150,16 @@ describe('when parsing ',function(){
|
||||
expect(edges[0].type).toBe('arrow_cross');
|
||||
});
|
||||
|
||||
it('should handle text on edges without space and space between vertices and link',function(){
|
||||
var res = flow.parser.parse('graph TD;A --x|textNoSpace| B;');
|
||||
|
||||
var vert = flow.parser.yy.getVertices();
|
||||
var edges = flow.parser.yy.getEdges();
|
||||
|
||||
|
||||
expect(edges[0].type).toBe('arrow_cross');
|
||||
});
|
||||
|
||||
it('should handle text on edges with space',function(){
|
||||
var res = flow.parser.parse('graph TD;A--x|text including space|B;');
|
||||
|
||||
@@ -218,6 +244,16 @@ describe('when parsing ',function(){
|
||||
expect(vert['A'].text).toBe('chimpansen hoppar');
|
||||
});
|
||||
|
||||
it('should handle text in vertices with space with spaces between vertices and link',function(){
|
||||
var res = flow.parser.parse('graph TD;A[chimpansen hoppar] --> C;');
|
||||
|
||||
var vert = flow.parser.yy.getVertices();
|
||||
var edges = flow.parser.yy.getEdges();
|
||||
|
||||
expect(vert['A'].type).toBe('square');
|
||||
expect(vert['A'].text).toBe('chimpansen hoppar');
|
||||
});
|
||||
|
||||
it('should handle text in circle vertices with space',function(){
|
||||
var res = flow.parser.parse('graph TD;A((chimpansen hoppar))-->C;');
|
||||
|
||||
|
Reference in New Issue
Block a user