mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-24 01:39:53 +02:00
Fix for issue with comments
This commit is contained in:
@@ -166,6 +166,22 @@ root
|
|||||||
`;
|
`;
|
||||||
// ::class1 class2
|
// ::class1 class2
|
||||||
|
|
||||||
|
mindmap.parse(str);
|
||||||
|
const mm = mindmap.yy.getMindmap();
|
||||||
|
expect(mm.nodeId).toEqual('root');
|
||||||
|
expect(mm.descr).toEqual('The root');
|
||||||
|
expect(mm.type).toEqual(mindmap.yy.nodeType.RECT);
|
||||||
|
expect(mm.class).toEqual('m-4 p-8');
|
||||||
|
expect(mm.icon).toEqual('bomb');
|
||||||
|
});
|
||||||
|
it('should be possible to set both classes and icon for the node', function () {
|
||||||
|
var str = `mindmap
|
||||||
|
root[The root]
|
||||||
|
::icon(bomb)
|
||||||
|
:::m-4 p-8
|
||||||
|
`;
|
||||||
|
// ::class1 class2
|
||||||
|
|
||||||
mindmap.parse(str);
|
mindmap.parse(str);
|
||||||
const mm = mindmap.yy.getMindmap();
|
const mm = mindmap.yy.getMindmap();
|
||||||
expect(mm.nodeId).toEqual('root');
|
expect(mm.nodeId).toEqual('root');
|
||||||
@@ -230,6 +246,45 @@ root
|
|||||||
expect(mm.descr).toEqual('Root');
|
expect(mm.descr).toEqual('Root');
|
||||||
expect(mm.children.length).toEqual(1);
|
expect(mm.children.length).toEqual(1);
|
||||||
|
|
||||||
|
const child = mm.children[0];
|
||||||
|
expect(child.nodeId).toEqual('Child');
|
||||||
|
expect(child.children[0].nodeId).toEqual('a');
|
||||||
|
expect(child.children.length).toEqual(2);
|
||||||
|
expect(child.children[1].nodeId).toEqual('b');
|
||||||
|
});
|
||||||
|
it('should be possible to have comments in a mindmap', function () {
|
||||||
|
var str = `mindmap
|
||||||
|
root(Root)
|
||||||
|
Child(Child)
|
||||||
|
a(a)
|
||||||
|
|
||||||
|
%% This is a comment
|
||||||
|
b[New Stuff]`;
|
||||||
|
mindmap.parse(str);
|
||||||
|
const mm = mindmap.yy.getMindmap();
|
||||||
|
expect(mm.nodeId).toEqual('root');
|
||||||
|
expect(mm.descr).toEqual('Root');
|
||||||
|
expect(mm.children.length).toEqual(1);
|
||||||
|
|
||||||
|
const child = mm.children[0];
|
||||||
|
expect(child.nodeId).toEqual('Child');
|
||||||
|
expect(child.children[0].nodeId).toEqual('a');
|
||||||
|
expect(child.children.length).toEqual(2);
|
||||||
|
expect(child.children[1].nodeId).toEqual('b');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be possible to have comments at the end of a line', function () {
|
||||||
|
var str = `mindmap
|
||||||
|
root(Root)
|
||||||
|
Child(Child)
|
||||||
|
a(a) %% This is a comment
|
||||||
|
b[New Stuff]`;
|
||||||
|
mindmap.parse(str);
|
||||||
|
const mm = mindmap.yy.getMindmap();
|
||||||
|
expect(mm.nodeId).toEqual('root');
|
||||||
|
expect(mm.descr).toEqual('Root');
|
||||||
|
expect(mm.children.length).toEqual(1);
|
||||||
|
|
||||||
const child = mm.children[0];
|
const child = mm.children[0];
|
||||||
expect(child.nodeId).toEqual('Child');
|
expect(child.nodeId).toEqual('Child');
|
||||||
expect(child.children[0].nodeId).toEqual('a');
|
expect(child.children[0].nodeId).toEqual('a');
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
\%\%.*\n {console.log('Found comment',yytext);} /* skip comments */
|
\s*\%\%.*\n {console.log('Found comment',yytext);}
|
||||||
// \%\%[^\n]*\n /* skip comments */
|
// \%\%[^\n]*\n /* skip comments */
|
||||||
"mindmap" return 'MINDMAP';
|
"mindmap" return 'MINDMAP';
|
||||||
":::" { this.begin('CLASS'); }
|
":::" { this.begin('CLASS'); }
|
||||||
|
Reference in New Issue
Block a user