Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(flowchart): Allow default in the node ID #2513

Merged
merged 5 commits into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cypress/integration/rendering/flowchart-v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ flowchart RL
imgSnapshotTest(
`flowchart TB
a{{"Lorem 'ipsum' dolor 'sit' amet, 'consectetur' adipiscing 'elit'."}}
--> b{{"Lorem #quot;ipsum#quot; dolor #quot;sit#quot; amet,#quot;consectetur#quot; adipiscing #quot;elit#quot;."}}
--> b{{"Lorem #quot;ipsum#quot; dolor #quot;sit#quot; amet,#quot;consectetur#quot; adipiscing #quot;elit#quot;."}}
`,
{ htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
);
Expand Down Expand Up @@ -638,4 +638,15 @@ flowchart RL
{ htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
);
});

it('2388: handling default in the node name', () => {
imgSnapshotTest(
`
flowchart LR
default-index.js --> dot.template.js
index.js --> module-utl.js
`,
{ htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
);
});
});
8 changes: 4 additions & 4 deletions dist/mermaid.core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mermaid.core.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mermaid.esm.min.mjs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/mermaid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mermaid.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mermaid.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mermaid.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/diagrams/flowchart/parser/flow.jison
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ direction

alphaNumToken : PUNCTUATION | AMP | UNICODE_TEXT | NUM| ALPHA | COLON | COMMA | PLUS | EQUALS | MULT | DOT | BRKT| UNDERSCORE ;

idStringToken : ALPHA|UNDERSCORE |UNICODE_TEXT | NUM| COLON | COMMA | PLUS | MINUS | DOWN |EQUALS | MULT | BRKT | DOT | PUNCTUATION | AMP;
idStringToken : ALPHA|UNDERSCORE |UNICODE_TEXT | NUM| COLON | COMMA | PLUS | MINUS | DOWN |EQUALS | MULT | BRKT | DOT | PUNCTUATION | AMP | DEFAULT;

graphCodeTokens: STADIUMSTART | STADIUMEND | SUBROUTINESTART | SUBROUTINEEND | VERTEX_WITH_PROPS_START | CYLINDERSTART | CYLINDEREND | TRAPSTART | TRAPEND | INVTRAPSTART | INVTRAPEND | PIPE | PS | PE | SQS | SQE | DIAMOND_START | DIAMOND_STOP | TAGSTART | TAGEND | ARROW_CROSS | ARROW_POINT | ARROW_CIRCLE | ARROW_OPEN | QUOTE | SEMI;
%%
12 changes: 12 additions & 0 deletions src/diagrams/flowchart/parser/flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ describe('when parsing ', function () {
expect(edges[0].end).toBe('monograph');
});

it('should allow default in the node name/id', function () {
const res = flow.parser.parse('graph TD\ndefault --> monograph');

const vert = flow.parser.yy.getVertices();
const edges = flow.parser.yy.getEdges();

expect(vert['default'].id).toBe('default');
expect(vert['monograph'].id).toBe('monograph');
expect(edges[0].start).toBe('default');
expect(edges[0].end).toBe('monograph');
});

describe('special characters should be be handled.', function () {
const charTest = function (char, result) {
const res = flow.parser.parse('graph TD;A(' + char + ')-->B;');
Expand Down