Compare commits

...

2 Commits

Author SHA1 Message Date
Shubham P
d93d9a521d Merge pull request #6820 from kriss-u/fix/6815_escape_namespace_class_diagram
fix: add classLiteral to the language for class diagram namespace
2025-08-06 08:12:54 +00:00
Krishna Upadhyay
c99bce6bab fix: add classLiteral to the language for class diagram namespace 2025-08-05 12:15:44 -05:00
4 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
fix: Add escaped class literal name on namespace

View File

@@ -512,4 +512,17 @@ describe('Class diagram', () => {
);
});
});
it('should handle backticks for namespace and class names', () => {
imgSnapshotTest(
`
classDiagram
namespace \`A::B\` {
class \`IPC::Sender\`
}
RenderProcessHost --|> \`IPC::Sender\`
`,
{}
);
});
});

View File

@@ -15,4 +15,12 @@ describe('class diagram', function () {
expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow();
});
});
describe('backtick escaping', function () {
it('should handle backtick-quoted namespace names', function () {
expect(() =>
parser.parse(`classDiagram\nnamespace \`A::B\` {\n\tclass \`IPC::Sender\`\n}`)
).not.toThrow();
});
});
});

View File

@@ -242,6 +242,7 @@ classLabel
namespaceName
: alphaNumToken { $$=$1; }
| classLiteralName { $$=$1; }
| alphaNumToken DOT namespaceName { $$=$1+'.'+$3; }
| alphaNumToken namespaceName { $$=$1+$2; }
;