Mermaid: Cannot mark members as protected in classDiagram

Created on 11 Nov 2019  路  8Comments  路  Source: mermaid-js/mermaid

Attempting to mark a member as protected in a class diagram by using the octothorpe (hash) character causes the graph to not render. I'm attempting this based on the classDiagram documentation.

Specifically, the following code:

classDiagram
class MyClass
MyClass : #mytest

Causes the following error:

Parse error on line 3:
...s MyClassMyClass : #mytest
----------------------^
Expecting 'NEWLINE', 'EOF', got 'PUNCTUATION'

The private, public and package qualifiers all seem to work appropriately.

This reproduces using the Mermaid Live Editor

I'm using Windows 10 with Chrome 78.0.3904.87

I can work around this cosmetically by using #35; but it took me a while to figure that out. It's unclear to me whether I lose any functionality by doing so. (I believe not.)

Development Retained Approved Bug / Error

Most helpful comment

I dont think you are inept. I would be surprised if this works, since it still starts with "#" which is defined as PUNCTUATION in the code :)

I am going to continue looking into this, in my attempts to get a better understanding of the mermaid code. Maybe I can even contribute ;)

All 8 comments

The documentation shows to use # for protected. I assume this SHOULD work as the opening post suggests. Kept as bug.

Interestingly, if you define the class with members inside of {}, this error does not happen. So it only appears to be when you are adding members individually

class BankAccount{
  +String onwer
  +BigDecimal balance
  #deposit(amount)
  +withdrawl(amount)
}

(Live Editor)

jgreywolf, that's good to know. Unfortunately, I can't use the {} syntax at this time due to a GitLab bug: https://gitlab.com/gitlab-org/gitlab/issues/35584

@ChristopherStryker Regarding your filled issue, the errors you described there are associated to older versions of mermaid. GitLab needs to update their mermaid version to resolve this issues. Especially the one with the reversed property order. That has been resolved in 8.3 I think.

Changing accounts, as I was signed in to the wrong one previously. Sorry for any potential confusion.

I assumed that GitLab needs to update their mermaid version to resolve the {} issue (and a couple others), but the original post still reproduces using the latest mermaid live editor, as linked.

Sorry for the double post, but as of this morning, the #35; workaround doesn't seem to work, unless I'm inept. Mermaid Live Editor

I dont think you are inept. I would be surprised if this works, since it still starts with "#" which is defined as PUNCTUATION in the code :)

I am going to continue looking into this, in my attempts to get a better understanding of the mermaid code. Maybe I can even contribute ;)

@jgreywolf great, can't wait for your contribution! Until then, I assigned this issue to you so nobody grabs it. Make sure to have a look into our contributing guidelines and join our Slack if you need assistance. You can find the invite link at the bottom of the page.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tokyo786 picture tokyo786  路  3Comments

lth946965333 picture lth946965333  路  3Comments

deftdawg picture deftdawg  路  3Comments

gvlx picture gvlx  路  5Comments

vi picture vi  路  5Comments