mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-14 19:49:39 +02:00
comments in states are skipped now
This commit is contained in:
@@ -184,6 +184,27 @@ describe('ClassDefs and classes when parsing a State diagram', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('comments parsing', () => {
|
||||||
|
it('working inside states', function () {
|
||||||
|
let diagram = '';
|
||||||
|
diagram += 'stateDiagram-v2\n\n';
|
||||||
|
diagram += '[*] --> Moving\n';
|
||||||
|
diagram += 'Moving --> Still\n';
|
||||||
|
diagram += 'Moving --> Crash\n';
|
||||||
|
diagram += 'state Moving {\n';
|
||||||
|
diagram += '%% comment inside state\n';
|
||||||
|
diagram += 'slow --> fast\n';
|
||||||
|
diagram += '}\n';
|
||||||
|
|
||||||
|
stateDiagram.parser.parse(diagram);
|
||||||
|
stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2());
|
||||||
|
|
||||||
|
const states = stateDiagram.parser.yy.getStates();
|
||||||
|
|
||||||
|
expect(states['Moving'].doc.length).toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -109,6 +109,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
|
|||||||
<STATE>[^\n\s\{]+ {/*console.log('COMPOSIT_STATE', yytext);*/return 'COMPOSIT_STATE';}
|
<STATE>[^\n\s\{]+ {/*console.log('COMPOSIT_STATE', yytext);*/return 'COMPOSIT_STATE';}
|
||||||
<STATE>\n {this.popState();}
|
<STATE>\n {this.popState();}
|
||||||
<INITIAL,STATE>\{ {this.popState();this.pushState('struct'); /*console.log('begin struct', yytext);*/return 'STRUCT_START';}
|
<INITIAL,STATE>\{ {this.popState();this.pushState('struct'); /*console.log('begin struct', yytext);*/return 'STRUCT_START';}
|
||||||
|
<struct>\%\%(?!\{)[^\n]* /* skip comments inside state*/
|
||||||
<struct>\} { /*console.log('Ending struct');*/ this.popState(); return 'STRUCT_STOP';}}
|
<struct>\} { /*console.log('Ending struct');*/ this.popState(); return 'STRUCT_STOP';}}
|
||||||
<struct>[\n] /* nothing */
|
<struct>[\n] /* nothing */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user