From bf457b37ee3b0fb07c36096d99d0f0b8c6eb0efe Mon Sep 17 00:00:00 2001 From: Elliot Scribner Date: Tue, 12 Dec 2023 11:53:11 -0800 Subject: [PATCH 1/5] Allow special chars in attributeName using backticks --- packages/mermaid/src/diagrams/er/parser/erDiagram.jison | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.jison b/packages/mermaid/src/diagrams/er/parser/erDiagram.jison index 135efc7846..6a71793024 100644 --- a/packages/mermaid/src/diagrams/er/parser/erDiagram.jison +++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.jison @@ -26,6 +26,7 @@ accDescr\s*"{"\s* { this.begin("acc_descr_multili \b((?:PK)|(?:FK)|(?:UK))\b return 'ATTRIBUTE_KEY' (.*?)[~](.*?)*[~] return 'ATTRIBUTE_WORD'; [\*A-Za-z_][A-Za-z0-9\-_\[\]\(\)]* return 'ATTRIBUTE_WORD' +\`[^`\n]*\` return 'BACKTICK_STRING'; \"[^"]*\" return 'COMMENT'; [\n]+ /* nothing */ "}" { this.popState(); return 'BLOCK_STOP'; } @@ -138,6 +139,7 @@ attributeType attributeName : ATTRIBUTE_WORD { $$=$1; } + | 'BACKTICK_STRING' { $$=$1.replace(/\`/g, ''); } ; attributeKeyTypeList From f09c1e0a0c237be6ce74c23a233857b417147261 Mon Sep 17 00:00:00 2001 From: Elliot Scribner Date: Tue, 12 Dec 2023 11:54:15 -0800 Subject: [PATCH 2/5] Add an example of special characters in demos/er.html --- demos/er.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/demos/er.html b/demos/er.html index 027c2e2772..e39e97aa95 100644 --- a/demos/er.html +++ b/demos/er.html @@ -140,6 +140,18 @@
+
+    erDiagram
+      hotel {
+          String address
+          String `city, state`
+          String `alias?`
+          String `"checkin"`
+          String `geo.accuracy`
+      }
+    
+
+