Skip to content

Commit

Permalink
updated check to avoid _ in shape syntax. updated readme path
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhg772244 committed Sep 24, 2024
1 parent b3dfc60 commit 1c8c953
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions docs/adding-new-shape/Readme.md → docs/adding-new-shape.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -126,7 +126,9 @@ To add a new shape:

const shapes = {
...,
myNewShape,
'my-new-shape': myNewShape,
// Shortened alias (if any).
'm-nsh': myNewShape
};
```

Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/flowchart/flowDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ To add a new shape:

const shapes = {
...,
myNewShape,
'my-new-shape': myNewShape,
// Shortened alias (if any).
'm-nsh': myNewShape
};
```

Expand Down

0 comments on commit 1c8c953

Please sign in to comment.