Added DIR element as valid text token, fix for issue #8

This commit is contained in:
knsv 2014-12-03 07:42:11 +01:00
parent ab78295faf
commit 7b09a6d1bf
3 changed files with 42 additions and 17 deletions

View File

@ -264,7 +264,10 @@ textToken: ALPHA
{$$ = $1;}
| MINUS
{$$ = $1;}
| DIR
{$$ = $1;}
;
textNoTags: textNoTagsToken
{$$=$1;}
| textNoTags textNoTagsToken
@ -293,6 +296,8 @@ textNoTagsToken: ALPHA
{$$ = $1;}
| MINUS
{$$ = $1;}
| DIR
{$$ = $1;}
;
classDefStatement:CLASSDEF SPACE alphaNum SPACE stylesOpt

File diff suppressed because one or more lines are too long

View File

@ -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;');
@ -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;');