Correct edge strings to have same configuration as vertex strings

This commit is contained in:
Ibrahim Wassouf
2023-07-26 22:36:57 -03:00
parent 9eed2e278b
commit d8897426cd
3 changed files with 5 additions and 2 deletions

View File

@@ -150,6 +150,7 @@ export const addSingleLink = function (_start, _end, type) {
if (linkTextObj !== undefined) { if (linkTextObj !== undefined) {
edge.text = sanitizeText(linkTextObj.text.trim()); edge.text = sanitizeText(linkTextObj.text.trim());
edge.text = edge.text.replaceAll('\\"', '"');
// strip quotes if string starts and ends with a quote // strip quotes if string starts and ends with a quote
if (edge.text[0] === '"' && edge.text[edge.text.length - 1] === '"') { if (edge.text[0] === '"' && edge.text[edge.text.length - 1] === '"') {
edge.text = edge.text.substring(1, edge.text.length - 1); edge.text = edge.text.substring(1, edge.text.length - 1);

View File

@@ -35,7 +35,7 @@ A["\`The cat in **the** hat\`"]-- "\`The *bat* in the chat\`" -->B["The dog in t
expect(edges[1].end).toBe('C'); expect(edges[1].end).toBe('C');
expect(edges[1].type).toBe('arrow_point'); expect(edges[1].type).toBe('arrow_point');
expect(edges[1].text).toBe('The rat in the mat'); expect(edges[1].text).toBe('The rat in the mat');
expect(edges[1].labelType).toBe('text'); expect(edges[1].labelType).toBe('string');
}); });
it('mardown formatting in subgraphs', function () { it('mardown formatting in subgraphs', function () {
const res = flow.parser.parse(`flowchart LR const res = flow.parser.parse(`flowchart LR

View File

@@ -462,6 +462,8 @@ edgeText: edgeTextToken
{$$={text:$edgeTextToken, type:'text'};} {$$={text:$edgeTextToken, type:'text'};}
| edgeText edgeTextToken | edgeText edgeTextToken
{$$={text:$edgeText.text+''+$edgeTextToken, type:$edgeText.type};} {$$={text:$edgeText.text+''+$edgeTextToken, type:$edgeText.type};}
|STR
{$$={text: $STR, type: 'string'};}
| MD_STR | MD_STR
{$$={text:$MD_STR, type:'markdown'};} {$$={text:$MD_STR, type:'markdown'};}
; ;
@@ -573,7 +575,7 @@ textToken : TEXT | TAGSTART | TAGEND | UNICODE_TEXT;
textNoTagsToken: NUM | NODE_STRING | SPACE | MINUS | keywords | START_LINK ; textNoTagsToken: NUM | NODE_STRING | SPACE | MINUS | keywords | START_LINK ;
edgeTextToken : STR | EDGE_TEXT | UNICODE_TEXT ; edgeTextToken : EDGE_TEXT | UNICODE_TEXT ;
alphaNumToken : NUM | UNICODE_TEXT | NODE_STRING | DIR | DOWN | MINUS | COMMA; alphaNumToken : NUM | UNICODE_TEXT | NODE_STRING | DIR | DOWN | MINUS | COMMA;