Skip to content

Commit

Permalink
Added DIR element as valid text token, fix for issue #8
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Dec 3, 2014
1 parent ab78295 commit 7b09a6d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
5 changes: 5 additions & 0 deletions src/parser/flow.jison
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ textToken: ALPHA
{$$ = $1;}
| MINUS
{$$ = $1;}
| DIR
{$$ = $1;}
;

textNoTags: textNoTagsToken
{$$=$1;}
| textNoTags textNoTagsToken
Expand Down Expand Up @@ -293,6 +296,8 @@ textNoTagsToken: ALPHA
{$$ = $1;}
| MINUS
{$$ = $1;}
| DIR
{$$ = $1;}
;

classDefStatement:CLASSDEF SPACE alphaNum SPACE stylesOpt
Expand Down
34 changes: 17 additions & 17 deletions src/parser/flow.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/parser/flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ describe('when parsing ',function(){

expect(edges[0].type).toBe('arrow_cross');
});
it('should handle text on edges with space dir',function(){
var res = flow.parser.parse('graph TD;A--x|text including URL space|B;');

var vert = flow.parser.yy.getVertices();
var edges = flow.parser.yy.getEdges();


expect(edges[0].type).toBe('arrow_cross');
expect(edges[0].text).toBe('text including URL space');

});
it('should handle multi-line text',function(){
var res = flow.parser.parse('graph TD;A--o|text space|B;\n B-->|more text with space|C;');

Expand Down Expand Up @@ -197,6 +208,15 @@ describe('when parsing ',function(){
expect(vert['C'].type).toBe('round');
expect(vert['C'].text).toBe('some CAPS');
});
it('should handle text in vertices with directions',function(){
var res = flow.parser.parse('graph TD;A-->C(some URL);');

var vert = flow.parser.yy.getVertices();
var edges = flow.parser.yy.getEdges();

expect(vert['C'].type).toBe('round');
expect(vert['C'].text).toBe('some URL');
});
it('should handle a single node',function(){
// Silly but syntactically correct
var res = flow.parser.parse('graph TD;A;');
Expand Down

0 comments on commit 7b09a6d

Please sign in to comment.