From 1c8c95367d7b319ec6dc3372ca6270c66c2c7cde Mon Sep 17 00:00:00 2001 From: saurabhg772244 Date: Tue, 24 Sep 2024 13:29:12 +0530 Subject: [PATCH] updated check to avoid _ in shape syntax. updated readme path --- docs/{adding-new-shape/Readme.md => adding-new-shape.md} | 6 ++++-- packages/mermaid/src/diagrams/flowchart/flowDb.ts | 2 +- .../{adding-new-shape/Readme.md => adding-new-shape.md} | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) rename docs/{adding-new-shape/Readme.md => adding-new-shape.md} (97%) rename packages/mermaid/src/docs/{adding-new-shape/Readme.md => adding-new-shape.md} (98%) diff --git a/docs/adding-new-shape/Readme.md b/docs/adding-new-shape.md similarity index 97% rename from docs/adding-new-shape/Readme.md rename to docs/adding-new-shape.md index 7d2c6eb811..b409d7c806 100644 --- a/docs/adding-new-shape/Readme.md +++ b/docs/adding-new-shape.md @@ -2,7 +2,7 @@ > > ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. > -> ## Please edit the corresponding file in [/packages/mermaid/src/docs/adding-new-shape/Readme.md](../../packages/mermaid/src/docs/adding-new-shape/Readme.md). +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/adding-new-shape.md](../packages/mermaid/src/docs/adding-new-shape.md). # Custom SVG Shapes Library @@ -126,7 +126,9 @@ To add a new shape: const shapes = { ..., - myNewShape, + 'my-new-shape': myNewShape, + // Shortened alias (if any). + 'm-nsh': myNewShape }; ``` diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.ts index 4785b27792..c94dffa498 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.ts @@ -133,7 +133,7 @@ export const addVertex = function ( } // console.log('yamlData', yamlData); const doc = yaml.load(yamlData, { schema: yaml.JSON_SCHEMA }) as NodeMetaData; - if (doc.shape && doc.shape !== doc.shape.toLowerCase()) { + if (doc.shape && (doc.shape !== doc.shape.toLowerCase() || doc.shape.includes('_'))) { throw new Error(`No such shape: ${doc.shape}. Shape names should be lowercase.`); } diff --git a/packages/mermaid/src/docs/adding-new-shape/Readme.md b/packages/mermaid/src/docs/adding-new-shape.md similarity index 98% rename from packages/mermaid/src/docs/adding-new-shape/Readme.md rename to packages/mermaid/src/docs/adding-new-shape.md index cf8f9b3fed..b04d5f7941 100644 --- a/packages/mermaid/src/docs/adding-new-shape/Readme.md +++ b/packages/mermaid/src/docs/adding-new-shape.md @@ -120,7 +120,9 @@ To add a new shape: const shapes = { ..., - myNewShape, + 'my-new-shape': myNewShape, + // Shortened alias (if any). + 'm-nsh': myNewShape }; ```