#915 Reviving the possibility to use underscore in text in vertices

This commit is contained in:
Knut Sveidqvist 2019-08-28 17:34:57 +02:00
parent a48a306fe8
commit 4ae48f4284
2 changed files with 26 additions and 1 deletions

View File

@ -552,7 +552,7 @@ alphaNumStatement
{$$='-';}
;
alphaNumToken : PUNCTUATION | UNICODE_TEXT | NUM| ALPHA | COLON | COMMA | PLUS | EQUALS | MULT | DOT | BRKT ;
alphaNumToken : PUNCTUATION | UNICODE_TEXT | NUM| ALPHA | COLON | COMMA | PLUS | EQUALS | MULT | DOT | BRKT| UNDERSCORE ;
idStringToken : ALPHA|UNDERSCORE |UNICODE_TEXT | NUM| COLON | COMMA | PLUS | MINUS | DOWN |EQUALS | MULT | BRKT | DOT | PUNCTUATION;

View File

@ -1158,6 +1158,15 @@ describe('when parsing ', function () {
expect(vert['A'].type).toBe('square')
expect(vert['A'].text).toBe('chimpansen hoppar')
})
it('should handle text including _ in vertices', function () {
const res = flow.parser.parse('graph TD;A[chimpansen_hoppar] --> C;')
const vert = flow.parser.yy.getVertices()
const edges = flow.parser.yy.getEdges()
expect(vert['A'].type).toBe('square')
expect(vert['A'].text).toBe('chimpansen_hoppar')
})
it('should handle quoted text in vertices ', function () {
const res = flow.parser.parse('graph TD;A["chimpansen hoppar ()[]"] --> C;')
@ -1613,6 +1622,22 @@ describe('when parsing ', function () {
expect(classes['exClass'].styles[0]).toBe('background:#bbb')
expect(classes['exClass'].styles[1]).toBe('border:1px solid red')
})
it('should be possible to apply a class to a vertex with an id containing _', function () {
let statement = ''
statement = statement + 'graph TD;' + '\n'
statement = statement + 'classDef exClass background:#bbb,border:1px solid red;' + '\n'
statement = statement + 'a_a-->b_b;' + '\n'
statement = statement + 'class a_a exClass;'
const res = flow.parser.parse(statement)
const classes = flow.parser.yy.getClasses()
expect(classes['exClass'].styles.length).toBe(2)
expect(classes['exClass'].styles[0]).toBe('background:#bbb')
expect(classes['exClass'].styles[1]).toBe('border:1px solid red')
})
it('should be possible to apply a class to a vertex directly', function () {
let statement = ''