Removing requirement to add ids for nodes with a shape

This commit is contained in:
Knut Sveidqvist 2022-09-05 14:53:01 +02:00
parent 8b4a08eef4
commit 8ad5f728c0
3 changed files with 36 additions and 29 deletions

View File

@ -33,7 +33,6 @@
display: none;
}
.mermaid {
}
.mermaid svg {
border: 1px solid purple;
@ -45,8 +44,8 @@
<body>
<pre class="mermaid" style="width: 50%">
mindmap
apa
bapa
[apa]
))bapa((
</pre>
<pre class="mermaid2" style="width: 50%">
flowchart TD
@ -62,21 +61,14 @@ flowchart TD
end
end
</div>
<div class="mermaid2" style="width: 50%;">
flowchart TD
id
</div>
<pre class="mermaid2" style="width: 50%;">
</pre>
<pre class="mermaid2" style="width: 50%">
flowchart LR
a["<strong>Haiya</strong>"]===>b
</pre>
<div class="mermaid2" style="width: 50%;">
flowchart TD
A --> B
A --> C
B --> C
</pre>
</pre
>
<div class="mermaid2" style="width: 50%">flowchart TD A --> B A --> C B --> C</div>
<pre class="mermaid2" style="width: 50%">
flowchart TD
A([stadium shape test])
@ -90,17 +82,12 @@ flowchart TD
classDef someclass fill:#f96;
class A someclass;
class C someclass;
</div>
<div class="mermaid2" style="width: 50%;">
sequenceDiagram
title: My Sequence Diagram Title
accTitle: My Acc Sequence Diagram
accDescr: My Sequence Diagram Description
Alice->>John: Hello John, how are you?
John-->>Alice: Great!
Alice-)John: See you later!
</pre>
<div class="mermaid2" style="width: 50%">
sequenceDiagram title: My Sequence Diagram Title accTitle: My Acc Sequence Diagram accDescr:
My Sequence Diagram Description Alice->>John: Hello John, how are you? John-->>Alice: Great!
Alice-)John: See you later!
</div>
<pre class="mermaid2" style="width: 50%">
graph TD
A -->|000| B

View File

@ -30,7 +30,17 @@ describe('when parsing a mindmap ', function () {
expect(mm.children[0].descr).toEqual('child1');
expect(mm.children[1].descr).toEqual('child2');
});
it('should handle a hierachial mindmap definition', function () {
it('should handle a simple root definition with a shape and without an id abc123', function () {
var str = `mindmap
(root)`;
mindmap.parse(str);
// console.log('Time for checks', mindmap.yy.getMindmap().descr);
expect(mindmap.yy.getMindmap().descr).toEqual('root');
});
it('should handle a deeper hierachial mindmap definition', function () {
var str = `mindmap
root
child1
@ -131,7 +141,7 @@ root
it('mutiple types (cloud)', function () {
var str = `mindmap
root))the root((
root)the root(
`;
mindmap.parse(str);
@ -256,7 +266,7 @@ root
expect(child.children[1].nodeId).toEqual('b');
});
});
it('should be possible to have meaningless empty rows in a mindmap abc123', function () {
it('should be possible to have meaningless empty rows in a mindmap abc124', function () {
var str = `mindmap
root(Root)
Child(Child)

View File

@ -86,6 +86,16 @@ statement
| EOF
;
node
:nodeWithId
|nodeWithoutId
;
nodeWithoutId
: NODE_DSTART NODE_DESCR NODE_DEND
{ console.log("node found ..", $1); $$ = { id: $2, descr: $2, type: yy.getType($1, $3) }; }
;
nodeWithId
: NODE_ID { $$ = { id: $1, descr: $1, type: yy.nodeType.DEFAULT }; }
| NODE_ID NODE_DSTART NODE_DESCR NODE_DEND
{ console.log("node found ..", $1); $$ = { id: $1, descr: $3, type: yy.getType($2, $4) }; }