From 1fa84a30c933eae2bf02cb74d3bfa3a6c0802778 Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Sun, 2 Oct 2022 17:07:34 +0200 Subject: [PATCH 1/5] Fill inheritance arrow with background color --- packages/mermaid/src/diagrams/class/styles.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/class/styles.js b/packages/mermaid/src/diagrams/class/styles.js index 9e7665c58..9dcda70f5 100644 --- a/packages/mermaid/src/diagrams/class/styles.js +++ b/packages/mermaid/src/diagrams/class/styles.js @@ -105,13 +105,13 @@ g.classGroup line { } #extensionStart, .extension { - fill: ${options.lineColor} !important; + fill: ${options.mainBkg} !important; stroke: ${options.lineColor} !important; stroke-width: 1; } #extensionEnd, .extension { - fill: ${options.lineColor} !important; + fill: ${options.mainBkg} !important; stroke: ${options.lineColor} !important; stroke-width: 1; } From 6eb2ce2706d5eed18693517e1467fa31981bcc93 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 25 Oct 2022 21:14:13 +0200 Subject: [PATCH 2/5] Ensure example code and rendered output are synced --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 6d5d26463..90ae1ad4c 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,6 @@ Class01 <|-- AveryLongClass : Cool Class09 --> C2 : Where am I? Class09 --* C3 Class09 --|> Class07 -note "I love this diagram!\nDo you love it?" Class07 : equals() Class07 : Object[] elementData Class01 : size() @@ -175,7 +174,6 @@ class Class10 { int id size() } -note for Class10 "Cool class\nI said it's very cool class!" ``` ### State diagram [docs - live editor] From caf95dec86bf1434fe70d3985bf95e59f4ad5bed Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Wed, 26 Oct 2022 16:57:19 -0400 Subject: [PATCH 3/5] fix(git): Support quoted branch names Fixes #3725 --- docs/gitgraph.md | 2 +- .../src/diagrams/git/gitGraphParserV2.spec.js | 25 +++++++++++ .../src/diagrams/git/parser/gitGraph.jison | 43 +++++++++++-------- packages/mermaid/src/docs/gitgraph.md | 2 +- 4 files changed, 51 insertions(+), 21 deletions(-) diff --git a/docs/gitgraph.md b/docs/gitgraph.md index 8efbf9fa5..878d1b3c1 100644 --- a/docs/gitgraph.md +++ b/docs/gitgraph.md @@ -165,7 +165,7 @@ In this example, we have given custom tags to the commits. Also, see how we have ### Create a new branch -In Mermaid, in-order to create a new branch, you make use of the `branch` keyword. You also need to provide a name of the new branch. The name has to be unique and cannot be that of an existing branch. Usage example: `branch develop` +In Mermaid, in-order to create a new branch, you make use of the `branch` keyword. You also need to provide a name of the new branch. The name has to be unique and cannot be that of an existing branch. A branch name that could be confused for a keyword must be quoted within `""`. Usage example: `branch develop` When Mermaid, reads the `branch` keyword, it creates a new branch and sets it as the current branch. Equivalent to you creating a new branch and checking it out in Git world. diff --git a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js index 7aab8fc7c..cad44ea1f 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js +++ b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js @@ -334,6 +334,31 @@ describe('when parsing a gitGraph', function () { expect(Object.keys(parser.yy.getBranches()).length).toBe(2); }); + it('should allow quoted branch names', function () { + const str = `gitGraph: + commit + branch "branch" + checkout "branch" + commit + checkout main + merge "branch" + `; + + parser.parse(str); + const commits = parser.yy.getCommits(); + expect(Object.keys(commits).length).toBe(3); + expect(parser.yy.getCurrentBranch()).toBe('main'); + expect(parser.yy.getDirection()).toBe('LR'); + expect(Object.keys(parser.yy.getBranches()).length).toBe(2); + const commit1 = Object.keys(commits)[0]; + const commit2 = Object.keys(commits)[1]; + const commit3 = Object.keys(commits)[2]; + expect(commits[commit1].branch).toBe('main'); + expect(commits[commit2].branch).toBe('branch'); + expect(commits[commit3].branch).toBe('main'); + expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'branch' }]); + }); + it('should allow _-./ characters in branch names', function () { const str = `gitGraph: commit diff --git a/packages/mermaid/src/diagrams/git/parser/gitGraph.jison b/packages/mermaid/src/diagrams/git/parser/gitGraph.jison index dbe220e15..1c87f3bf3 100644 --- a/packages/mermaid/src/diagrams/git/parser/gitGraph.jison +++ b/packages/mermaid/src/diagrams/git/parser/gitGraph.jison @@ -109,12 +109,12 @@ statement | acc_descr acc_descr_value { $$=$2.trim();yy.setAccDescription($$); } | acc_descr_multiline_value { $$=$1.trim();yy.setAccDescription($$); } | section {yy.addSection($1.substr(8));$$=$1.substr(8);} | branchStatement - | CHECKOUT ID {yy.checkout($2)} + | CHECKOUT ref {yy.checkout($2)} // | RESET reset_arg {yy.reset($2)} ; branchStatement - : BRANCH ID {yy.branch($2)} - | BRANCH ID ORDER NUM {yy.branch($2, $4)} + : BRANCH ref {yy.branch($2)} + | BRANCH ref ORDER NUM {yy.branch($2, $4)} ; cherryPickStatement @@ -126,22 +126,22 @@ cherryPickStatement ; mergeStatement - : MERGE ID {yy.merge($2,'','','')} - | MERGE ID COMMIT_ID STR {yy.merge($2, $4,'','')} - | MERGE ID COMMIT_TYPE commitType {yy.merge($2,'', $4,'')} - | MERGE ID COMMIT_TAG STR {yy.merge($2, '','',$4)} - | MERGE ID COMMIT_TAG STR COMMIT_ID STR {yy.merge($2, $6,'', $4)} - | MERGE ID COMMIT_TAG STR COMMIT_TYPE commitType {yy.merge($2, '',$6, $4)} - | MERGE ID COMMIT_TYPE commitType COMMIT_TAG STR {yy.merge($2, '',$4, $6)} - | MERGE ID COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $4, $6, '')} - | MERGE ID COMMIT_ID STR COMMIT_TAG STR {yy.merge($2, $4, '', $6)} - | MERGE ID COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $6,$4, '')} - | MERGE ID COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.merge($2, $4, $6, $8)} - | MERGE ID COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR {yy.merge($2, $8, $4, $6)} - | MERGE ID COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.merge($2, $4, $8, $6)} - | MERGE ID COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR {yy.merge($2, $6, $4, $8)} - | MERGE ID COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $8, $6, $4)} - | MERGE ID COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $6, $8, $4)} + : MERGE ref {yy.merge($2,'','','')} + | MERGE ref COMMIT_ID STR {yy.merge($2, $4,'','')} + | MERGE ref COMMIT_TYPE commitType {yy.merge($2,'', $4,'')} + | MERGE ref COMMIT_TAG STR {yy.merge($2, '','',$4)} + | MERGE ref COMMIT_TAG STR COMMIT_ID STR {yy.merge($2, $6,'', $4)} + | MERGE ref COMMIT_TAG STR COMMIT_TYPE commitType {yy.merge($2, '',$6, $4)} + | MERGE ref COMMIT_TYPE commitType COMMIT_TAG STR {yy.merge($2, '',$4, $6)} + | MERGE ref COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $4, $6, '')} + | MERGE ref COMMIT_ID STR COMMIT_TAG STR {yy.merge($2, $4, '', $6)} + | MERGE ref COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $6,$4, '')} + | MERGE ref COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.merge($2, $4, $6, $8)} + | MERGE ref COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR {yy.merge($2, $8, $4, $6)} + | MERGE ref COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.merge($2, $4, $8, $6)} + | MERGE ref COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR {yy.merge($2, $6, $4, $8)} + | MERGE ref COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $8, $6, $4)} + | MERGE ref COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $6, $8, $4)} ; commitStatement @@ -261,6 +261,11 @@ closeDirective : close_directive { yy.parseDirective('}%%', 'close_directive', 'gitGraph'); } ; +ref + : ID + | STR + ; + eol : NL | ';' diff --git a/packages/mermaid/src/docs/gitgraph.md b/packages/mermaid/src/docs/gitgraph.md index f82b88ca1..a7033adb8 100644 --- a/packages/mermaid/src/docs/gitgraph.md +++ b/packages/mermaid/src/docs/gitgraph.md @@ -114,7 +114,7 @@ In this example, we have given custom tags to the commits. Also, see how we have ### Create a new branch -In Mermaid, in-order to create a new branch, you make use of the `branch` keyword. You also need to provide a name of the new branch. The name has to be unique and cannot be that of an existing branch. Usage example: `branch develop` +In Mermaid, in-order to create a new branch, you make use of the `branch` keyword. You also need to provide a name of the new branch. The name has to be unique and cannot be that of an existing branch. A branch name that could be confused for a keyword must be quoted within `""`. Usage example: `branch develop` When Mermaid, reads the `branch` keyword, it creates a new branch and sets it as the current branch. Equivalent to you creating a new branch and checking it out in Git world. From 6293a583a4f490fd24259b75643bf73ad09a2df0 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 27 Oct 2022 23:35:25 -0400 Subject: [PATCH 4/5] docs(git): Add a quoted branch name example --- packages/mermaid/src/docs/gitgraph.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/docs/gitgraph.md b/packages/mermaid/src/docs/gitgraph.md index a7033adb8..b8e399e09 100644 --- a/packages/mermaid/src/docs/gitgraph.md +++ b/packages/mermaid/src/docs/gitgraph.md @@ -114,7 +114,7 @@ In this example, we have given custom tags to the commits. Also, see how we have ### Create a new branch -In Mermaid, in-order to create a new branch, you make use of the `branch` keyword. You also need to provide a name of the new branch. The name has to be unique and cannot be that of an existing branch. A branch name that could be confused for a keyword must be quoted within `""`. Usage example: `branch develop` +In Mermaid, in-order to create a new branch, you make use of the `branch` keyword. You also need to provide a name of the new branch. The name has to be unique and cannot be that of an existing branch. A branch name that could be confused for a keyword must be quoted within `""`. Usage examples: `branch develop`, `branch "cherry-pick"` When Mermaid, reads the `branch` keyword, it creates a new branch and sets it as the current branch. Equivalent to you creating a new branch and checking it out in Git world. From 033f88e8bb581c1d18a52de7f3dab0c05af8b2de Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 27 Oct 2022 23:41:07 -0400 Subject: [PATCH 5/5] docs(git): Regenerate --- docs/gitgraph.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gitgraph.md b/docs/gitgraph.md index 878d1b3c1..baa75126e 100644 --- a/docs/gitgraph.md +++ b/docs/gitgraph.md @@ -165,7 +165,7 @@ In this example, we have given custom tags to the commits. Also, see how we have ### Create a new branch -In Mermaid, in-order to create a new branch, you make use of the `branch` keyword. You also need to provide a name of the new branch. The name has to be unique and cannot be that of an existing branch. A branch name that could be confused for a keyword must be quoted within `""`. Usage example: `branch develop` +In Mermaid, in-order to create a new branch, you make use of the `branch` keyword. You also need to provide a name of the new branch. The name has to be unique and cannot be that of an existing branch. A branch name that could be confused for a keyword must be quoted within `""`. Usage examples: `branch develop`, `branch "cherry-pick"` When Mermaid, reads the `branch` keyword, it creates a new branch and sets it as the current branch. Equivalent to you creating a new branch and checking it out in Git world.