mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 07:49:43 +02:00
Support dashes in actor names in sequence diagrams
This commit is contained in:
@@ -58,10 +58,10 @@
|
|||||||
"deactivate" { this.begin('ID'); return 'deactivate'; }
|
"deactivate" { this.begin('ID'); return 'deactivate'; }
|
||||||
"title" return 'title';
|
"title" return 'title';
|
||||||
"sequenceDiagram" return 'SD';
|
"sequenceDiagram" return 'SD';
|
||||||
"autonumber" return 'autonumber';
|
"autonumber" return 'autonumber';
|
||||||
"," return ',';
|
"," return ',';
|
||||||
";" return 'NL';
|
";" return 'NL';
|
||||||
[^\+\->:\n,;]+ { yytext = yytext.trim(); return 'ACTOR'; }
|
[^\+\->:\n,;]+((?!(\-x|\-\-x))[\-]*[^\+\->:\n,;]+)* { yytext = yytext.trim(); return 'ACTOR'; }
|
||||||
"->>" return 'SOLID_ARROW';
|
"->>" return 'SOLID_ARROW';
|
||||||
"-->>" return 'DOTTED_ARROW';
|
"-->>" return 'DOTTED_ARROW';
|
||||||
"->" return 'SOLID_OPEN_ARROW';
|
"->" return 'SOLID_OPEN_ARROW';
|
||||||
|
@@ -93,6 +93,23 @@ Bob-->Alice: I am good thanks!`;
|
|||||||
expect(messages[0].from).toBe('Alice');
|
expect(messages[0].from).toBe('Alice');
|
||||||
expect(messages[1].from).toBe('Bob');
|
expect(messages[1].from).toBe('Bob');
|
||||||
});
|
});
|
||||||
|
it('it should handle dashes in actor names', function() {
|
||||||
|
const str = `
|
||||||
|
sequenceDiagram
|
||||||
|
Alice-in-Wonderland->Bob:Hello Bob, how are - you?
|
||||||
|
Bob-->Alice-in-Wonderland:I am good thanks!`;
|
||||||
|
|
||||||
|
mermaidAPI.parse(str);
|
||||||
|
const actors = parser.yy.getActors();
|
||||||
|
expect(actors["Alice-in-Wonderland"].description).toBe('Alice-in-Wonderland');
|
||||||
|
actors.Bob.description = 'Bob';
|
||||||
|
|
||||||
|
const messages = parser.yy.getMessages();
|
||||||
|
|
||||||
|
expect(messages.length).toBe(2);
|
||||||
|
expect(messages[0].from).toBe('Alice-in-Wonderland');
|
||||||
|
expect(messages[1].from).toBe('Bob');
|
||||||
|
});
|
||||||
it('it should alias participants', function() {
|
it('it should alias participants', function() {
|
||||||
const str = `
|
const str = `
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
|
Reference in New Issue
Block a user