Compare commits

...

3 Commits

Author SHA1 Message Date
github-merge-queue[bot]
9dec41fd10 Update docs 2023-09-05 09:01:44 +00:00
Sidharth Vinod
39527eae1d Merge pull request #4776 from tomperr/fix/4775_allow-leading-underscore-entity-name
fix(er): allow underscore as leading char
2023-09-05 08:57:13 +00:00
Tom PERRILLAT-COLLOMB
264f7920f0 fix(er): allow underscore as leading char 2023-08-27 00:15:50 +02:00
7 changed files with 29 additions and 6 deletions

View File

@@ -125,6 +125,21 @@
</pre> </pre>
<hr /> <hr />
<pre class="mermaid">
erDiagram
_customer_order {
bigint id PK
bigint customer_id FK
text shipping_address
text delivery_method
timestamp_with_time_zone ordered_at
numeric total_tax_amount
numeric total_price
text payment_method
}
</pre>
<hr />
<script type="module"> <script type="module">
import mermaid from './mermaid.esm.mjs'; import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ mermaid.initialize({

View File

@@ -49,6 +49,7 @@ They also serve as proof of concept, for the variety of things that can be built
- [Mermaid plugin for GitBook](https://github.com/wwformat/gitbook-plugin-mermaid-pdf) - [Mermaid plugin for GitBook](https://github.com/wwformat/gitbook-plugin-mermaid-pdf)
- [LiveBook](https://livebook.dev) (**Native support**) - [LiveBook](https://livebook.dev) (**Native support**)
- [Atlassian Products](https://www.atlassian.com) - [Atlassian Products](https://www.atlassian.com)
- [Mermaid Live Editor for Confluence Cloud](https://marketplace.atlassian.com/apps/1231571/mermaid-live-editor-for-confluence?hosting=cloud&tab=overview)
- [Mermaid Plugin for Confluence](https://marketplace.atlassian.com/apps/1214124/mermaid-plugin-for-confluence?hosting=server&tab=overview) - [Mermaid Plugin for Confluence](https://marketplace.atlassian.com/apps/1214124/mermaid-plugin-for-confluence?hosting=server&tab=overview)
- [CloudScript.io Addon](https://marketplace.atlassian.com/apps/1219878/cloudscript-io-mermaid-addon?hosting=cloud&tab=overview) - [CloudScript.io Addon](https://marketplace.atlassian.com/apps/1219878/cloudscript-io-mermaid-addon?hosting=cloud&tab=overview)
- [Auto convert diagrams in Jira](https://github.com/coddingtonbear/jirafs-mermaid) - [Auto convert diagrams in Jira](https://github.com/coddingtonbear/jirafs-mermaid)
@@ -89,7 +90,7 @@ They also serve as proof of concept, for the variety of things that can be built
## Communication ## Communication
- [Discourse](https://discourse.org) - [Discourse](https://discourse.org)
- [Mermaid Theme Component](https://meta.discourse.org/t/discourse-mermaid/218242) - [Mermaid Plugin](https://github.com/pnewell/discourse-mermaid), [And](https://github.com/unfoldingWord-dev/discourse-mermaid)
- [Mattermost](https://mattermost.com/) - [Mattermost](https://mattermost.com/)
- [Mermaid Plugin](https://github.com/SpikeTings/Mermaid) - [Mermaid Plugin](https://github.com/SpikeTings/Mermaid)
- [phpBB](https://phpbb.com) - [phpBB](https://phpbb.com)

View File

@@ -90,7 +90,7 @@ Mermaid syntax for ER diagrams is compatible with PlantUML, with an extension to
Where: Where:
- `first-entity` is the name of an entity. Names must begin with an alphabetic character and may also contain digits, hyphens, and underscores. - `first-entity` is the name of an entity. Names must begin with an alphabetic character or an underscore (from v\<MERMAID_RELEASE_VERSION>+), and may also contain digits and hyphens.
- `relationship` describes the way that both entities inter-relate. See below. - `relationship` describes the way that both entities inter-relate. See below.
- `second-entity` is the name of the other entity. - `second-entity` is the name of the other entity.
- `relationship-label` describes the relationship from the perspective of the first entity. - `relationship-label` describes the relationship from the perspective of the first entity.

View File

@@ -467,7 +467,7 @@ flowchart TB
A & B--> C & D A & B--> C & D
``` ```
If you describe the same diagram using the basic syntax, it will take four lines. A If you describe the same diagram using the the basic syntax, it will take four lines. A
word of warning, one could go overboard with this making the flowchart harder to read in word of warning, one could go overboard with this making the flowchart harder to read in
markdown form. The Swedish word `lagom` comes to mind. It means, not too much and not too little. markdown form. The Swedish word `lagom` comes to mind. It means, not too much and not too little.
This goes for expressive syntaxes as well. This goes for expressive syntaxes as well.

View File

@@ -66,7 +66,7 @@ o\{ return 'ZERO_OR_MORE';
"optionally to" return 'NON_IDENTIFYING'; "optionally to" return 'NON_IDENTIFYING';
\.\- return 'NON_IDENTIFYING'; \.\- return 'NON_IDENTIFYING';
\-\. return 'NON_IDENTIFYING'; \-\. return 'NON_IDENTIFYING';
[A-Za-z][A-Za-z0-9\-_]* return 'ALPHANUM'; [A-Za-z_][A-Za-z0-9\-_]* return 'ALPHANUM';
. return yytext[0]; . return yytext[0];
<<EOF>> return 'EOF'; <<EOF>> return 'EOF';

View File

@@ -33,7 +33,7 @@ describe('when parsing ER diagram it...', function () {
describe('has non A-Za-z0-9_- chars', function () { describe('has non A-Za-z0-9_- chars', function () {
// these were entered using the Mac keyboard utility. // these were entered using the Mac keyboard utility.
const chars = const chars =
"~ ` ! @ # $ ^ & * ( ) - _ = + [ ] { } | / ; : ' . ? ¡ ™ € £ ¢ ∞ fi § ‡ • ° ª · º ≠ ± œ Œ ∑ „ ® † ˇ ¥ Á ¨ ˆ ˆ Ø π ∏ “ « » å Å ß Í ∂ Î ƒ Ï © ˙ Ó ∆ Ô ˚  ¬ Ò … Ú æ Æ Ω ¸ ≈ π ˛ ç Ç √ ◊ ∫ ı ˜ µ  ≤ ¯ ≥ ˘ ÷ ¿"; "~ ` ! @ # $ ^ & * ( ) - = + [ ] { } | / ; : ' . ? ¡ ™ € £ ¢ ∞ fi § ‡ • ° ª · º ≠ ± œ Œ ∑ „ ® † ˇ ¥ Á ¨ ˆ ˆ Ø π ∏ “ « » å Å ß Í ∂ Î ƒ Ï © ˙ Ó ∆ Ô ˚  ¬ Ò … Ú æ Æ Ω ¸ ≈ π ˛ ç Ç √ ◊ ∫ ı ˜ µ  ≤ ¯ ≥ ˘ ÷ ¿";
const allowed = chars.split(' '); const allowed = chars.split(' ');
allowed.forEach((allowedChar) => { allowed.forEach((allowedChar) => {
@@ -170,6 +170,13 @@ describe('when parsing ER diagram it...', function () {
expect(entities[firstEntity].alias).toBe(alias); expect(entities[firstEntity].alias).toBe(alias);
expect(entities[secondEntity].alias).toBeUndefined(); expect(entities[secondEntity].alias).toBeUndefined();
}); });
it('can start with an underscore', function () {
const entity = '_foo';
erDiagram.parser.parse(`erDiagram\n${entity}\n`);
const entities = erDb.getEntities();
expect(entities.hasOwnProperty(entity)).toBe(true);
});
}); });
describe('attribute name', () => { describe('attribute name', () => {

View File

@@ -56,7 +56,7 @@ Mermaid syntax for ER diagrams is compatible with PlantUML, with an extension to
Where: Where:
- `first-entity` is the name of an entity. Names must begin with an alphabetic character and may also contain digits, hyphens, and underscores. - `first-entity` is the name of an entity. Names must begin with an alphabetic character or an underscore (from v<MERMAID_RELEASE_VERSION>+), and may also contain digits and hyphens.
- `relationship` describes the way that both entities inter-relate. See below. - `relationship` describes the way that both entities inter-relate. See below.
- `second-entity` is the name of the other entity. - `second-entity` is the name of the other entity.
- `relationship-label` describes the relationship from the perspective of the first entity. - `relationship-label` describes the relationship from the perspective of the first entity.