mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
Merge pull request #6820 from kriss-u/fix/6815_escape_namespace_class_diagram
fix: add classLiteral to the language for class diagram namespace
This commit is contained in:
5
.changeset/rare-women-fly.md
Normal file
5
.changeset/rare-women-fly.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'mermaid': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Add escaped class literal name on namespace
|
@@ -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\`
|
||||||
|
`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -15,4 +15,12 @@ describe('class diagram', function () {
|
|||||||
expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow();
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -242,6 +242,7 @@ classLabel
|
|||||||
|
|
||||||
namespaceName
|
namespaceName
|
||||||
: alphaNumToken { $$=$1; }
|
: alphaNumToken { $$=$1; }
|
||||||
|
| classLiteralName { $$=$1; }
|
||||||
| alphaNumToken DOT namespaceName { $$=$1+'.'+$3; }
|
| alphaNumToken DOT namespaceName { $$=$1+'.'+$3; }
|
||||||
| alphaNumToken namespaceName { $$=$1+$2; }
|
| alphaNumToken namespaceName { $$=$1+$2; }
|
||||||
;
|
;
|
||||||
|
Reference in New Issue
Block a user