Skip to content

Commit

Permalink
#4012 Neater grammar for the rows before mindmap
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Jan 20, 2023
1 parent 80903e4 commit bc56a7d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
12 changes: 12 additions & 0 deletions packages/mermaid-mindmap/src/mindmap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,18 @@ root
expect(mm.nodeId).toEqual('root');
expect(mm.children.length).toEqual(2);

const child = mm.children[0];
expect(child.nodeId).toEqual('A');
const child2 = mm.children[1];
expect(child2.nodeId).toEqual('B');
});
it('MMP-25 Handle rows above the mindmap declarations, no space', function () {
let str = '\n\n\nmindmap\nroot\n A\n \n\n B';
mindmap.parse(str);
const mm = mindmap.yy.getMindmap();
expect(mm.nodeId).toEqual('root');
expect(mm.children.length).toEqual(2);

const child = mm.children[0];
expect(child.nodeId).toEqual('A');
const child2 = mm.children[1];
Expand Down
13 changes: 8 additions & 5 deletions packages/mermaid-mindmap/src/parser/mindmap.jison
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,21 @@

start
// %{ : info document 'EOF' { return yy; } }
: MINDMAP document { return yy; }
| MINDMAP NL document { return yy; }
| spaceLines MINDMAP document { return yy; }
| spaceLines MINDMAP NL document { return yy; }
;
: mindMap
| spaceLines mindMap
;

spaceLines
: SPACELINE
| spaceLines SPACELINE
| spaceLines NL
;

mindMap
: MINDMAP document { return yy; }
| MINDMAP NL document { return yy; }
;

stop
: NL {yy.getLogger().trace('Stop NL ');}
| EOF {yy.getLogger().trace('Stop EOF ');}
Expand Down

0 comments on commit bc56a7d

Please sign in to comment.