mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 06:49:47 +02:00
@@ -136,9 +136,10 @@ statements
|
||||
|
||||
|
||||
spaceListNewline
|
||||
: spaceList
|
||||
: SPACE spaceListNewline
|
||||
| NEWLINE spaceListNewline
|
||||
| NEWLINE
|
||||
| SPACE
|
||||
;
|
||||
|
||||
|
||||
@@ -243,10 +244,6 @@ text: textToken
|
||||
{$$=$1+''+$2;}
|
||||
;
|
||||
|
||||
textStatement: textToken
|
||||
| textToken textStatement
|
||||
;
|
||||
|
||||
textToken: ALPHA
|
||||
{$$=$1;}
|
||||
| NUM
|
||||
@@ -276,6 +273,73 @@ textToken: ALPHA
|
||||
| keywords
|
||||
{$$ = $1;}
|
||||
;
|
||||
|
||||
commentText: commentToken
|
||||
{$$=$1;}
|
||||
| commentText commentToken
|
||||
{$$=$1+''+$2;}
|
||||
;
|
||||
|
||||
commentToken: ALPHA
|
||||
{$$=$1;}
|
||||
| NUM
|
||||
{$$=$1;}
|
||||
| COLON
|
||||
{$$ = $1;}
|
||||
| COMMA
|
||||
{$$ = $1;}
|
||||
| PLUS
|
||||
{$$ = $1;}
|
||||
| EQUALS
|
||||
{$$ = $1;}
|
||||
| MULT
|
||||
{$$ = $1;}
|
||||
| DOT
|
||||
{$$ = $1;}
|
||||
| TAGSTART
|
||||
{$$ = $1;}
|
||||
| TAGEND
|
||||
{$$ = $1;}
|
||||
| BRKT
|
||||
{$$ = '<br>';}
|
||||
| PIPE
|
||||
{$$ = '<br>';}
|
||||
| PS
|
||||
{$$ = '<br>';}
|
||||
| PE
|
||||
{$$ = '<br>';}
|
||||
| SQS
|
||||
{$$ = '<br>';}
|
||||
| SQE
|
||||
{$$ = '<br>';}
|
||||
| DIAMOND_START
|
||||
{$$ = '<br>';}
|
||||
| DIAMOND_STOP
|
||||
{$$ = '<br>';}
|
||||
| TAG_START
|
||||
{$$ = '<br>';}
|
||||
| TAG_END
|
||||
{$$ = '<br>';}
|
||||
| ARROW_CROSS
|
||||
{$$ = '<br>';}
|
||||
| ARROW_POINT
|
||||
{$$ = '<br>';}
|
||||
| ARROW_CIRCLE
|
||||
{$$ = '<br>';}
|
||||
| ARROW_OPEN
|
||||
{$$ = '<br>';}
|
||||
| QUOTE
|
||||
{$$ = '<br>';}
|
||||
| SPACE
|
||||
{$$ = $1;}
|
||||
| MINUS
|
||||
{$$ = $1;}
|
||||
| SEMI
|
||||
{$$ = $1;}
|
||||
| keywords
|
||||
{$$ = $1;}
|
||||
;
|
||||
|
||||
keywords
|
||||
: STYLE | LINKSTYLE | CLASSDEF | CLASS | CLICK | GRAPH | DIR;
|
||||
|
||||
@@ -335,7 +399,7 @@ linkStyleStatement:
|
||||
{$$ = $1;yy.updateLink($3,$5);}
|
||||
;
|
||||
commentStatement:
|
||||
PCT PCT text
|
||||
PCT PCT commentText
|
||||
{$$ = $1;}
|
||||
;
|
||||
stylesOpt: style
|
||||
|
File diff suppressed because one or more lines are too long
@@ -62,6 +62,38 @@ describe('when parsing ',function(){
|
||||
expect(edges[0].text).toBe('');
|
||||
});
|
||||
|
||||
it('should handle a comments mermaid flowchart code in them',function(){
|
||||
var res = flow.parser.parse('graph TD;\n\n\n %% Test od>Odd shape]-->|Two line<br>edge comment|ro;\n 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('it should handle a trailing whitespaces after statememnts',function(){
|
||||
var res = flow.parser.parse('graph TD;\n\n\n %% CComment\n A-->B; \nB-->C;');
|
||||
|
||||
|
||||
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(2);
|
||||
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 open ended edges',function(){
|
||||
var res = flow.parser.parse('graph TD;A---B;');
|
||||
|
||||
|
@@ -24,7 +24,7 @@ str = str + 'bfs:someNode.setLevel';
|
||||
//console.log(sq.parse(str));
|
||||
|
||||
|
||||
describe('when parsing ',function() {
|
||||
describe('when parsing a sequence it',function() {
|
||||
var parseError;
|
||||
beforeEach(function () {
|
||||
sq = require('./parser/sequence').parser;
|
||||
|
Reference in New Issue
Block a user