mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 23:39:50 +02:00
Allow end
as a substring of vertex id
Jison adds \b (word boundary) to literal string patterns by default. It does so, because it doesn't follow traditional match-longest approach, but does match-first instead. Without including word boundaries, it'd be hard to distinguish between a keyword and identifier. The pattern for `end` keyword is not a simple string literal - it swallows trailing whitespace, so we have to add \b manually. This partially fixes #184 - at least now `end` behaves the same as other keywords: it can be used as a prefix and infix, but not as a suffix. To solve this issue completely, ALPHA pattern would have to match multiple letters, which is a much bigger change.
This commit is contained in:
@@ -308,6 +308,18 @@ describe('when parsing ',function(){
|
||||
expect(edges[0].text).toBe('');
|
||||
});
|
||||
|
||||
it('should handle node names with "end" substring',function(){
|
||||
var res = flow.parser.parse('graph TD\nendpoint --> sender');
|
||||
|
||||
var vert = flow.parser.yy.getVertices();
|
||||
var edges = flow.parser.yy.getEdges();
|
||||
|
||||
expect(vert['endpoint'].id).toBe('endpoint');
|
||||
expect(vert['sender'].id).toBe('sender');
|
||||
expect(edges[0].start).toBe('endpoint');
|
||||
expect(edges[0].end).toBe('sender');
|
||||
});
|
||||
|
||||
it('should handle open ended edges',function(){
|
||||
var res = flow.parser.parse('graph TD;A---B;');
|
||||
|
||||
|
Reference in New Issue
Block a user