Compare commits

...

6 Commits

Author SHA1 Message Date
darshanr0107
33bc4a0b4e chore: added changeset
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
2025-08-29 19:34:29 +05:30
darshanr0107
c6f25167a2 fix: handle newline characters as whitespace
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
2025-08-29 19:21:05 +05:30
Sidharth Vinod
7171237b96 Merge pull request #6865 from mermaid-js/renovate/peter-evans-create-pull-request-digest
chore(deps): update peter-evans/create-pull-request digest to cb4d3bf
2025-08-20 00:07:42 +05:30
Shubham P
066883f4cd Merge branch 'develop' into renovate/peter-evans-create-pull-request-digest 2025-08-19 19:01:50 +05:30
autofix-ci[bot]
c534d3d364 [autofix.ci] apply automated fixes 2025-08-18 11:46:12 +00:00
renovate[bot]
4db72f5357 chore(deps): update peter-evans/create-pull-request digest to cb4d3bf 2025-08-18 11:31:20 +00:00
5 changed files with 36 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
fix: Render newlines as spaces in class diagrams

View File

@@ -58,7 +58,7 @@ jobs:
echo "EOF" >> $GITHUB_OUTPUT
- name: Commit and create pull request
uses: peter-evans/create-pull-request@1310d7dab503600742045e6fd4b84dda64352858
uses: peter-evans/create-pull-request@cb4d3bfce175d44325c6b7697f81e0afe8a79bdf
with:
add-paths: |
cypress/timings.json

View File

@@ -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' } }
);
});
});
});

View File

@@ -1070,6 +1070,14 @@ describe('given a class diagram with members and methods ', function () {
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);
});
});
});

View File

@@ -293,6 +293,7 @@ classStatement
: classIdentifier
| classIdentifier STYLE_SEPARATOR alphaNumToken {yy.setCssClass($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);}
;
@@ -301,8 +302,15 @@ classIdentifier
| CLASS className classLabel {$$=$2; yy.addClass($2);yy.setClassLabel($2, $3);}
;
emptyBody
:
| SPACE emptyBody
| NEWLINE emptyBody
;
annotationStatement
:ANNOTATION_START alphaNumToken ANNOTATION_END className { yy.addAnnotation($4,$2); }
: ANNOTATION_START alphaNumToken ANNOTATION_END className { yy.addAnnotation($4,$2); }
;
members