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

Added version to package.json and circled actors #145

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Next Next commit
Add support for quoted actors with special chars.
  • Loading branch information
eloyesp committed Dec 3, 2015
commit e7fdebb49d4caca4e0d4714dd91650c2277e6247
2 changes: 1 addition & 1 deletion src/diagram.js
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@

Diagram.unescape = function(s) {
// Turn "\\n" into "\n"
return s.trim().replace(/\\n/gm, "\n");
return s.trim().replace(/^"(.*)"$/m, "$1").replace(/\\n/gm, "\n");
};

Diagram.LINETYPE = {
3 changes: 2 additions & 1 deletion src/grammar.jison
Original file line number Diff line number Diff line change
@@ -23,7 +23,8 @@
"note" return 'note';
"title" return 'title';
"," return ',';
[^\->:,\r\n]+ return 'ACTOR';
[^\->:,\r\n"]+ return 'ACTOR';
\"[^"]+\" return 'ACTOR';
"--" return 'DOTLINE';
"-" return 'LINE';
">>" return 'OPENARROW';
6 changes: 6 additions & 0 deletions test/grammar-tests.js
Original file line number Diff line number Diff line change
@@ -181,6 +181,12 @@ test( "Newlines", function() {
assertSingleActor(Diagram.parse("Participant A\r\nNote left of A: Hello"), "A");
});

test( "Quoted names", function() {
assertSingleArrow(Diagram.parse("\"->:\"->B: M"), ARROWTYPE.FILLED, LINETYPE.SOLID, "->:", "B", "M");
assertSingleArrow(Diagram.parse("A->\"->:\": M"), ARROWTYPE.FILLED, LINETYPE.SOLID, "A", "->:", "M");
assertSingleActor(Diagram.parse("Participant \"->:\""), "->:");
});

test( "API", function() {
// Public API
ok(typeof Diagram.parse == "function");