Skip to content

Commit b773fd5

Browse files
author
Anthony Juckel
committed
Re-enable equal sign in sequence diagram participants
1 parent 446f6a7 commit b773fd5

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

packages/mermaid/src/diagrams/sequence/parser/sequenceDiagram.jison

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"actor" { this.begin('ID'); return 'participant_actor'; }
3434
"create" return 'create';
3535
"destroy" { this.begin('ID'); return 'destroy'; }
36-
<ID>[^\<->\->:\n,;]+?([\-]*[^\<->\->:\n,;]+?)*?(?=((?!\n)\s)+"as"(?!\n)\s|[#\n;]|$) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
36+
<ID>[^<\->\->:\n,;]+?([\-]*[^<\->\->:\n,;]+?)*?(?=((?!\n)\s)+"as"(?!\n)\s|[#\n;]|$) { yytext = yytext.trim(); this.begin('ALIAS'); return 'ACTOR'; }
3737
<ALIAS>"as" { this.popState(); this.popState(); this.begin('LINE'); return 'AS'; }
3838
<ALIAS>(?:) { this.popState(); this.popState(); return 'NEWLINE'; }
3939
"loop" { this.begin('LINE'); return 'loop'; }
@@ -73,7 +73,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
7373
"off" return 'off';
7474
"," return ',';
7575
";" return 'NEWLINE';
76-
[^\+\<->\->:\n,;]+((?!(\-x|\-\-x|\-\)|\-\-\)))[\-]*[^\+\<->\->:\n,;]+)* { yytext = yytext.trim(); return 'ACTOR'; }
76+
[^+<\->\->:\n,;]+((?!(\-x|\-\-x|\-\)|\-\-\)))[\-]*[^\+<\->\->:\n,;]+)* { yytext = yytext.trim(); return 'ACTOR'; }
7777
"->>" return 'SOLID_ARROW';
7878
"<<->>" return 'BIDIRECTIONAL_SOLID_ARROW';
7979
"-->>" return 'DOTTED_ARROW';

packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js

+20
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,26 @@ Bob-->Alice-in-Wonderland:I am good thanks!`);
350350
expect(messages[1].from).toBe('Bob');
351351
});
352352

353+
it('should handle equals in participant names', async () => {
354+
const diagram = await Diagram.fromText(`
355+
sequenceDiagram
356+
participant Alice=Wonderland
357+
participant Bob
358+
Alice=Wonderland->Bob:Hello Bob, how are - you?
359+
Bob-->Alice=Wonderland:I am good thanks!`);
360+
361+
const actors = diagram.db.getActors();
362+
expect([...actors.keys()]).toEqual(['Alice=Wonderland', 'Bob']);
363+
expect(actors.get('Alice=Wonderland').description).toBe('Alice=Wonderland');
364+
expect(actors.get('Bob').description).toBe('Bob');
365+
366+
const messages = diagram.db.getMessages();
367+
368+
expect(messages.length).toBe(2);
369+
expect(messages[0].from).toBe('Alice=Wonderland');
370+
expect(messages[1].from).toBe('Bob');
371+
});
372+
353373
it('should alias participants', async () => {
354374
const diagram = await Diagram.fromText(`
355375
sequenceDiagram

0 commit comments

Comments
 (0)