Only allow quotes to wrap entire string

This commit is contained in:
Ibrahim Wassouf
2023-07-24 21:23:21 -03:00
parent 4cfbd0d380
commit 651274bc6f
2 changed files with 6 additions and 10 deletions

View File

@@ -691,15 +691,9 @@ describe('[Text] when parsing', () => {
expect(edges[0].text).toBe(',.?!+-*');
});
it('should handle strings and text at the same time', function () {
const res = flow.parser.parse(
'graph TD;A(this node has "string" and text)-->|this link has "string" and text|C;'
);
it('should throw error for strings and text at the same time', function () {
const str = 'graph TD;A(this node has "string" and text)-->|this link has "string" and text|C;';
const vert = flow.parser.yy.getVertices();
const edges = flow.parser.yy.getEdges();
expect(vert['A'].text).toBe('this node has "string" and text');
expect(edges[0].text).toBe('this link has "string" and text');
expect(() => flow.parser.parse(str)).toThrowError("got 'STR'");
});
});

View File

@@ -480,6 +480,8 @@ text: textToken
{ $$={text:$textToken, type: 'text'};}
| text textToken
{ $$={text:$text.text+''+$textToken, type: $text.type};}
| STR
{$$={text: $STR, type: 'text'};}
| MD_STR
{ $$={text: $MD_STR, type: 'markdown'};}
;
@@ -567,7 +569,7 @@ styleComponent: NUM | NODE_STRING| COLON | UNIT | SPACE | BRKT | STYLE | PCT ;
/* Token lists */
idStringToken : NUM | NODE_STRING | DOWN | MINUS | DEFAULT | COMMA | COLON;
textToken : STR | TEXT | TAGSTART | TAGEND | UNICODE_TEXT;
textToken : TEXT | TAGSTART | TAGEND | UNICODE_TEXT;
textNoTagsToken: NUM | NODE_STRING | SPACE | MINUS | keywords | START_LINK ;