Skip to content

Commit c99bce6

Browse files
committed
fix: add classLiteral to the language for class diagram namespace
1 parent 4ab98c2 commit c99bce6

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

.changeset/rare-women-fly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mermaid': patch
3+
---
4+
5+
fix: Add escaped class literal name on namespace

cypress/integration/rendering/classDiagram.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,4 +512,17 @@ describe('Class diagram', () => {
512512
);
513513
});
514514
});
515+
516+
it('should handle backticks for namespace and class names', () => {
517+
imgSnapshotTest(
518+
`
519+
classDiagram
520+
namespace \`A::B\` {
521+
class \`IPC::Sender\`
522+
}
523+
RenderProcessHost --|> \`IPC::Sender\`
524+
`,
525+
{}
526+
);
527+
});
515528
});

packages/mermaid/src/diagrams/class/parser/class.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ describe('class diagram', function () {
1515
expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow();
1616
});
1717
});
18+
19+
describe('backtick escaping', function () {
20+
it('should handle backtick-quoted namespace names', function () {
21+
expect(() =>
22+
parser.parse(`classDiagram\nnamespace \`A::B\` {\n\tclass \`IPC::Sender\`\n}`)
23+
).not.toThrow();
24+
});
25+
});
1826
});

packages/mermaid/src/diagrams/class/parser/classDiagram.jison

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ classLabel
242242

243243
namespaceName
244244
: alphaNumToken { $$=$1; }
245+
| classLiteralName { $$=$1; }
245246
| alphaNumToken DOT namespaceName { $$=$1+'.'+$3; }
246247
| alphaNumToken namespaceName { $$=$1+$2; }
247248
;

0 commit comments

Comments
 (0)