diff --git a/docs/mindmap.md b/docs/mindmap.md index 6ab954f5b6..8a7e21eb7f 100644 --- a/docs/mindmap.md +++ b/docs/mindmap.md @@ -2,8 +2,6 @@ # Mindmap -**Edit this Page** [![N|Solid](img/GitHub-Mark-32px.png)](https://github.com/mermaid-js/mermaid/blob/develop/src/docs/mindmap.md) - > Mindmap: This is an experimental diagram for now. The syntax and properties can change in future releases. The syntax is stabel except for the icon integration which is the experimental part. "A mind map is a diagram used to visually organize information into a hierarchy, showing relationships among pieces of the whole. It is often created around a single concept, drawn as an image in the center of a blank page, to which associated representations of ideas such as images, words and parts of words are added. Major ideas are connected directly to the central concept, and other ideas branch out from those major ideas." Wikipedia diff --git a/src/diagrams/git/gitGraphParserV2.spec.js b/src/diagrams/git/gitGraphParserV2.spec.js index 56a11a8760..fcf965d71e 100644 --- a/src/diagrams/git/gitGraphParserV2.spec.js +++ b/src/diagrams/git/gitGraphParserV2.spec.js @@ -363,6 +363,34 @@ describe('when parsing a gitGraph', function () { expect(Object.keys(parser.yy.getBranches()).length).toBe(2); }); + it('should allow branch names starting with unusual prefixes', function () { + const str = `gitGraph: + commit + %% branch names starting with numbers are not recommended, but are supported by git + branch branch01 + branch checkout02 + branch cherry-pick03 + branch branch/example-branch + branch merge/test_merge + `; + + parser.parse(str); + const commits = parser.yy.getCommits(); + expect(Object.keys(commits).length).toBe(1); + expect(parser.yy.getCurrentBranch()).toBe('merge/test_merge'); + expect(parser.yy.getDirection()).toBe('LR'); + expect(Object.keys(parser.yy.getBranches()).length).toBe(6); + expect(Object.keys(parser.yy.getBranches())).toEqual( + expect.arrayContaining([ + 'branch01', + 'checkout02', + 'cherry-pick03', + 'branch/example-branch', + 'merge/test_merge', + ]) + ); + }); + it('should handle new branch checkout', function () { const str = `gitGraph: commit diff --git a/src/diagrams/git/parser/gitGraph.jison b/src/diagrams/git/parser/gitGraph.jison index 29edec8083..15909a3143 100644 --- a/src/diagrams/git/parser/gitGraph.jison +++ b/src/diagrams/git/parser/gitGraph.jison @@ -36,7 +36,7 @@ accDescr\s*"{"\s* { this.begin("ac \#[^\n]* /* skip comments */ \%%[^\n]* /* skip comments */ "gitGraph" return 'GG'; -"commit" return 'COMMIT'; +commit(?=\s|$) return 'COMMIT'; "id:" return 'COMMIT_ID'; "type:" return 'COMMIT_TYPE'; "msg:" return 'COMMIT_MSG'; @@ -44,12 +44,12 @@ accDescr\s*"{"\s* { this.begin("ac "REVERSE" return 'REVERSE'; "HIGHLIGHT" return 'HIGHLIGHT'; "tag:" return 'COMMIT_TAG'; -"branch" return 'BRANCH'; +branch(?=\s|$) return 'BRANCH'; "order:" return 'ORDER'; -"merge" return 'MERGE'; -"cherry-pick" return 'CHERRY_PICK'; +merge(?=\s|$) return 'MERGE'; +cherry-pick(?=\s|$) return 'CHERRY_PICK'; // "reset" return 'RESET'; -"checkout" return 'CHECKOUT'; +checkout(?=\s|$) return 'CHECKOUT'; "LR" return 'DIR'; "BT" return 'DIR'; ":" return ':'; diff --git a/src/docs/mindmap.md b/src/docs/mindmap.md index d7f1b48171..85a05e04b5 100644 --- a/src/docs/mindmap.md +++ b/src/docs/mindmap.md @@ -1,7 +1,5 @@ # Mindmap -**Edit this Page** [![N|Solid](img/GitHub-Mark-32px.png)](https://github.com/mermaid-js/mermaid/blob/develop/src/docs/mindmap.md) - > Mindmap: This is an experimental diagram for now. The syntax and properties can change in future releases. The syntax is stabel except for the icon integration which is the experimental part. "A mind map is a diagram used to visually organize information into a hierarchy, showing relationships among pieces of the whole. It is often created around a single concept, drawn as an image in the center of a blank page, to which associated representations of ideas such as images, words and parts of words are added. Major ideas are connected directly to the central concept, and other ideas branch out from those major ideas." Wikipedia diff --git a/yarn.lock b/yarn.lock index 58c3d2818f..8b0ce83d11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3937,9 +3937,9 @@ camelcase@^6.2.0: integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== caniuse-lite@^1.0.30001359: - version "1.0.30001390" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001390.tgz" - integrity sha512-sS4CaUM+/+vqQUlCvCJ2WtDlV81aWtHhqeEVkLokVJJa3ViN4zDxAGfq9R8i1m90uGHxo99cy10Od+lvn3hf0g== + version "1.0.30001397" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001397.tgz" + integrity sha512-SW9N2TbCdLf0eiNDRrrQXx2sOkaakNZbCjgNpPyMJJbiOrU5QzMIrXOVMRM1myBXTD5iTkdrtU/EguCrBocHlA== caseless@~0.12.0: version "0.12.0"