From 80903e427ce2031002e2ac15f28bdf8d34cdc381 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 20 Jan 2023 10:18:26 +0100 Subject: [PATCH] #4012 Allowing multiple lines before the mindmap statement --- packages/mermaid-mindmap/src/mindmap.spec.js | 12 ++++++++++++ packages/mermaid-mindmap/src/parser/mindmap.jison | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/mermaid-mindmap/src/mindmap.spec.js b/packages/mermaid-mindmap/src/mindmap.spec.js index 2a2dd13bb..292d7ebf8 100644 --- a/packages/mermaid-mindmap/src/mindmap.spec.js +++ b/packages/mermaid-mindmap/src/mindmap.spec.js @@ -354,6 +354,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-24 Handle rows above the mindmap declarations', function () { + let str = '\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]; diff --git a/packages/mermaid-mindmap/src/parser/mindmap.jison b/packages/mermaid-mindmap/src/parser/mindmap.jison index 651d9dc09..b604d3b1e 100644 --- a/packages/mermaid-mindmap/src/parser/mindmap.jison +++ b/packages/mermaid-mindmap/src/parser/mindmap.jison @@ -67,9 +67,16 @@ start // %{ : info document 'EOF' { return yy; } } : MINDMAP document { return yy; } | MINDMAP NL document { return yy; } - | SPACELIST MINDMAP document { return yy; } + | spaceLines MINDMAP document { return yy; } + | spaceLines MINDMAP NL document { return yy; } ; +spaceLines + : SPACELINE + | spaceLines SPACELINE + | spaceLines NL + ; + stop : NL {yy.getLogger().trace('Stop NL ');} | EOF {yy.getLogger().trace('Stop EOF ');}