mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 17:29:54 +02:00
Allow entity diagram attribute names to start with asterisk
This commit is contained in:
@@ -30,7 +30,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili
|
|||||||
<block>\s+ /* skip whitespace in block */
|
<block>\s+ /* skip whitespace in block */
|
||||||
<block>\b((?:PK)|(?:FK)|(?:UK))\b return 'ATTRIBUTE_KEY'
|
<block>\b((?:PK)|(?:FK)|(?:UK))\b return 'ATTRIBUTE_KEY'
|
||||||
<block>(.*?)[~](.*?)*[~] return 'ATTRIBUTE_WORD';
|
<block>(.*?)[~](.*?)*[~] return 'ATTRIBUTE_WORD';
|
||||||
<block>[A-Za-z_][A-Za-z0-9\-_\[\]\(\)]* return 'ATTRIBUTE_WORD'
|
<block>[\*A-Za-z_][A-Za-z0-9\-_\[\]\(\)]* return 'ATTRIBUTE_WORD'
|
||||||
<block>\"[^"]*\" return 'COMMENT';
|
<block>\"[^"]*\" return 'COMMENT';
|
||||||
<block>[\n]+ /* nothing */
|
<block>[\n]+ /* nothing */
|
||||||
<block>"}" { this.popState(); return 'BLOCK_STOP'; }
|
<block>"}" { this.popState(); return 'BLOCK_STOP'; }
|
||||||
|
@@ -154,6 +154,16 @@ describe('when parsing ER diagram it...', function () {
|
|||||||
expect(entities[entity].attributes[2].attributeName).toBe('author-ref[name](1)');
|
expect(entities[entity].attributes[2].attributeName).toBe('author-ref[name](1)');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow asterisk at the start of title', function () {
|
||||||
|
const entity = 'BOOK';
|
||||||
|
const attribute = 'string *title';
|
||||||
|
|
||||||
|
erDiagram.parser.parse(`erDiagram\n${entity}{${attribute}}`);
|
||||||
|
const entities = erDb.getEntities();
|
||||||
|
expect(Object.keys(entities).length).toBe(1);
|
||||||
|
expect(entities[entity].attributes.length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('should not allow leading numbers, dashes or brackets', function () {
|
it('should not allow leading numbers, dashes or brackets', function () {
|
||||||
const entity = 'BOOK';
|
const entity = 'BOOK';
|
||||||
const nonLeadingChars = '0-[]()';
|
const nonLeadingChars = '0-[]()';
|
||||||
|
Reference in New Issue
Block a user