mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-09 02:27:05 +02:00
fix: handle newline characters as whitespace
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -524,5 +524,18 @@ describe('Class diagram', () => {
|
|||||||
`,
|
`,
|
||||||
{}
|
{}
|
||||||
);
|
);
|
||||||
|
it('should handle an empty class body with empty braces', () => {
|
||||||
|
imgSnapshotTest(
|
||||||
|
` classDiagram
|
||||||
|
class FooBase~T~ {}
|
||||||
|
class Bar {
|
||||||
|
+Zip
|
||||||
|
+Zap()
|
||||||
|
}
|
||||||
|
FooBase <|-- Ba
|
||||||
|
`,
|
||||||
|
{ flowchart: { defaultRenderer: 'elk' } }
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1070,6 +1070,14 @@ describe('given a class diagram with members and methods ', function () {
|
|||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
});
|
});
|
||||||
|
it('should handle an empty class body with {}', function () {
|
||||||
|
const str = 'classDiagram\nclass EmptyClass {}';
|
||||||
|
parser.parse(str);
|
||||||
|
const actual = parser.yy.getClass('EmptyClass');
|
||||||
|
expect(actual.label).toBe('EmptyClass');
|
||||||
|
expect(actual.members.length).toBe(0);
|
||||||
|
expect(actual.methods.length).toBe(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -293,6 +293,7 @@ classStatement
|
|||||||
: classIdentifier
|
: classIdentifier
|
||||||
| classIdentifier STYLE_SEPARATOR alphaNumToken {yy.setCssClass($1, $3);}
|
| classIdentifier STYLE_SEPARATOR alphaNumToken {yy.setCssClass($1, $3);}
|
||||||
| classIdentifier STRUCT_START members STRUCT_STOP {yy.addMembers($1,$3);}
|
| classIdentifier STRUCT_START members STRUCT_STOP {yy.addMembers($1,$3);}
|
||||||
|
| classIdentifier STRUCT_START STRUCT_STOP {}
|
||||||
| classIdentifier STYLE_SEPARATOR alphaNumToken STRUCT_START members STRUCT_STOP {yy.setCssClass($1, $3);yy.addMembers($1,$5);}
|
| classIdentifier STYLE_SEPARATOR alphaNumToken STRUCT_START members STRUCT_STOP {yy.setCssClass($1, $3);yy.addMembers($1,$5);}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -301,8 +302,15 @@ classIdentifier
|
|||||||
| CLASS className classLabel {$$=$2; yy.addClass($2);yy.setClassLabel($2, $3);}
|
| CLASS className classLabel {$$=$2; yy.addClass($2);yy.setClassLabel($2, $3);}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
emptyBody
|
||||||
|
:
|
||||||
|
| SPACE emptyBody
|
||||||
|
| NEWLINE emptyBody
|
||||||
|
;
|
||||||
|
|
||||||
annotationStatement
|
annotationStatement
|
||||||
:ANNOTATION_START alphaNumToken ANNOTATION_END className { yy.addAnnotation($4,$2); }
|
: ANNOTATION_START alphaNumToken ANNOTATION_END className { yy.addAnnotation($4,$2); }
|
||||||
;
|
;
|
||||||
|
|
||||||
members
|
members
|
||||||
|
Reference in New Issue
Block a user