mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-12-02 10:34:22 +01:00
Only allow quotes to wrap entire string
This commit is contained in:
@@ -691,15 +691,9 @@ describe('[Text] when parsing', () => {
|
|||||||
expect(edges[0].text).toBe(',.?!+-*');
|
expect(edges[0].text).toBe(',.?!+-*');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle strings and text at the same time', function () {
|
it('should throw error for strings and text at the same time', function () {
|
||||||
const res = flow.parser.parse(
|
const str = 'graph TD;A(this node has "string" and text)-->|this link has "string" and text|C;';
|
||||||
'graph TD;A(this node has "string" and text)-->|this link has "string" and text|C;'
|
|
||||||
);
|
|
||||||
|
|
||||||
const vert = flow.parser.yy.getVertices();
|
expect(() => flow.parser.parse(str)).toThrowError("got 'STR'");
|
||||||
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');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -480,6 +480,8 @@ text: textToken
|
|||||||
{ $$={text:$textToken, type: 'text'};}
|
{ $$={text:$textToken, type: 'text'};}
|
||||||
| text textToken
|
| text textToken
|
||||||
{ $$={text:$text.text+''+$textToken, type: $text.type};}
|
{ $$={text:$text.text+''+$textToken, type: $text.type};}
|
||||||
|
| STR
|
||||||
|
{$$={text: $STR, type: 'text'};}
|
||||||
| MD_STR
|
| MD_STR
|
||||||
{ $$={text: $MD_STR, type: 'markdown'};}
|
{ $$={text: $MD_STR, type: 'markdown'};}
|
||||||
;
|
;
|
||||||
@@ -567,7 +569,7 @@ styleComponent: NUM | NODE_STRING| COLON | UNIT | SPACE | BRKT | STYLE | PCT ;
|
|||||||
/* Token lists */
|
/* Token lists */
|
||||||
idStringToken : NUM | NODE_STRING | DOWN | MINUS | DEFAULT | COMMA | COLON;
|
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 ;
|
textNoTagsToken: NUM | NODE_STRING | SPACE | MINUS | keywords | START_LINK ;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user