Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces in subgraph titles no longer render in Mermaid 8.2.3 #895

Closed
stanhu opened this issue Jul 30, 2019 · 9 comments
Closed

Spaces in subgraph titles no longer render in Mermaid 8.2.3 #895

stanhu opened this issue Jul 30, 2019 · 9 comments
Assignees

Comments

@stanhu
Copy link
Contributor

stanhu commented Jul 30, 2019

Describe the bug

Using a title with spaces results in the error:

Parse error on line 11:
...;  subgraph Mobile Units    vetronics
---------------------^
Expecting 'SEMI', 'NEWLINE', 'EOF', 'DIR', 'DOWN', 'SQS', 'MINUS', 'NUM', 'COMMA', 'ALPHA', 'COLON', 'BRKT', 'DOT', 'PUNCTUATION', 'UNICODE_TEXT', 'PLUS', 'EQUALS', 'MULT', got 'SPACE'

To Reproduce

Use the sample graph: https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggQlQ7XG5cbiAgdmV0cm9uaWNzIC0tLSB1aHVyYTtcbiAgb2J1IC0tLSB1aHVyYTtcbiAgZG9uZ2xlIC0tLSB1aHVyYTtcbiAga2Fma2EgLS0tIHVodXJhO1xuICB4bXBwIC0tLSB1aHVyYTtcbiAga2Fma2EgLS0tIHRvbGw7XG4gIGthZmthIC0tLSB0ZWxlO1xuXG4gIHN1YmdyYXBoIE1vYmlsZSBVbml0c1xuICAgIHZldHJvbmljc1tWZXRyb25pY3NdO1xuICAgIG9idVtUb2xsIE9CVV07XG4gICAgZG9uZ2xlW0RvbmdsZV07XG4gIGVuZFxuXG4gIHN1YmdyYXBoIFwiVWh1cmEgQ2x1c3RlclwiXG4gICAgdWh1cmFbVWh1cmFdO1xuICAgIGNvbnN1bFtDb25zdWxdO1xuICAgIGNpZnNbU2hhcmVkIEZpbGVzeXN0ZW1dO1xuICAgIGNvbnN1bCAtLS0gdWh1cmE7XG4gICAgdWh1cmEgLS0tIGNpZnM7XG4gIGVuZFxuXG4gIHN1YmdyYXBoIEludGVyZmFjZVxuICAgIGthZmthW0thZmthXTtcbiAgICB4bXBwW1hNUFBdO1xuICBlbmRcblxuICBzdWJncmFwaCBDbGllbnRzXG4gICAgdG9sbFtUb2xsIFBsYXRmb3JtXTtcbiAgICB0ZWxlW1RlbGVtYXRpY3NdO1xuICBlbmQiLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9fQ/error/UGFyc2UgZXJyb3Igb24gbGluZSAxMToKLi4uOyAgc3ViZ3JhcGggTW9iaWxlIFVuaXRzICAgIHZldHJvbmljcwotLS0tLS0tLS0tLS0tLS0tLS0tLS1eCkV4cGVjdGluZyAnU0VNSScsICdORVdMSU5FJywgJ0VPRicsICdESVInLCAnRE9XTicsICdTUVMnLCAnTUlOVVMnLCAnTlVNJywgJ0NPTU1BJywgJ0FMUEhBJywgJ0NPTE9OJywgJ0JSS1QnLCAnRE9UJywgJ1BVTkNUVUFUSU9OJywgJ1VOSUNPREVfVEVYVCcsICdQTFVTJywgJ0VRVUFMUycsICdNVUxUJywgZ290ICdTUEFDRSc

graph BT;

  vetronics --- uhura;
  obu --- uhura;
  dongle --- uhura;
  kafka --- uhura;
  xmpp --- uhura;
  kafka --- toll;
  kafka --- tele;

  subgraph Mobile Units
    vetronics[Vetronics];
    obu[Toll OBU];
    dongle[Dongle];
  end

  subgraph "Uhura Cluster"
    uhura[Uhura];
    consul[Consul];
    cifs[Shared Filesystem];
    consul --- uhura;
    uhura --- cifs;
  end

  subgraph Interface
    kafka[Kafka];
    xmpp[XMPP];
  end

  subgraph Clients
    toll[Toll Platform];
    tele[Telematics];
  end
Loading

Expected behavior

Subgraphs render.

Screenshots

Desktop (please complete the following information):

  • OS: MacOS
  • Browser Chrome

Additional context

@stanhu
Copy link
Contributor Author

stanhu commented Jul 30, 2019

This problem was not in 8.0.0, but seems to have been introduced in 8.1.0 via #845.

@spbert29
Copy link

You need to write "Mobile Unit" with Quotes

@stanhu
Copy link
Contributor Author

stanhu commented Jul 31, 2019

Right, this surprised a number of our users. I asked whether we can preserve backwards compatibility: #845 (comment)

@stanhu stanhu closed this as completed Jul 31, 2019
@knsv
Copy link
Collaborator

knsv commented Aug 3, 2019

Let move this here. I encourage backwards compatability and think this needs some investigating. I will reopen this issue for this discussion.

@knsv knsv reopened this Aug 3, 2019
@sagea
Copy link
Contributor

sagea commented Aug 4, 2019

Thinking aloud:

So after doing a bit of research. In this case we should consider the text a title under the assumption we don't see the id[*] syntax.

Known details

  1. This was broken in 8.x but worked fine in the last 7.x version.
  2. Prior to the 8.0.0 release, brackets in the title threw an error when not surrounded by quotes. This means that none of our users had titles that looked like this a["foo"] prior to 7.x

Assumptions:

  1. Id's should be able to start with numbers. (This is currently broken: subgraph fails to render when subgraph ID starts with a number #900)
  2. We aren't going to account for escaping characters because that feature isn't there today.
  3. We aren't going to account for trailing or extra spaces because that hasn't changed.

So these are the possible formats...

%% No style id and considered text
subgraph "a b"
subgraph old style that is broken
subgraph a-b-c

%% with style id
subgraph uid1[text of doom]
subgraph uid2["text of doom"]
subgraph uid3[abcdef]
Loading

These are the different types of things that can technically exist. (not jijson)

  • unquoted title
  • quoted title
  • bracketed title
  • id

@knsv
Copy link
Collaborator

knsv commented Aug 14, 2019

It should be possible to handle the "old style that is broken" as long as it does not contain a bracket.

@knsv knsv self-assigned this Aug 15, 2019
knsv added a commit that referenced this issue Aug 16, 2019
@knsv
Copy link
Collaborator

knsv commented Aug 26, 2019

Fixed as of v 8.2.4

@knsv knsv closed this as completed Aug 26, 2019
@nynevi
Copy link

nynevi commented Feb 15, 2023

for those that stumble upon the same problem while linking subgraphs in a flowchart as such:

A --> Sub Graph Name (spaces in the name)

subgraph Sub Graph Name
or
subgraph "Sub Graph Name"

I've found the examples given here in this issue helpful #895 (comment) so I ended up with:

A --> graphId

subgraph graphId[Sub Graph Name]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants