mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
68.79k stars 6.08k forks source link

Typing a semicolon creates a new state node instead of being included in the transition text #5410

Open anlai46 opened 3 months ago

anlai46 commented 3 months ago

Description

When using the live editor to create a state diagram in Mermaid.js, I encountered an issue where typing a semicolon ";" in the text description of a transition results in the semicolon and everything after it being interpreted as the name of a new state node. This could lead users to accidentally create new state nodes and mess up the original layout of the state diagram.

Steps to reproduce

  1. Open Mermaid live editor.
  2. Create a simple state diagram with transition arrow between two state nodes
  3. Type a semicolon in the text description for the transition.
  4. See that a new node is created and named with the semicolon and everything after

Screenshots

Expected Behavior:

image

Actual Behavior:

image

Code Sample

---
title: lastTtoA
---
stateDiagram 
    direction LR

    classDef badBadEvent 
    fill:#f00,color:white,font-weight:bold,stroke-width:2px,stroke:yellow

    q0 --> q0
    q0 --> q1
    q1 --> q1
    q1 --> qHalt:::badBadEvent: T;A,S

Setup

Suggested Solutions

Additional Context

No response

nirname commented 2 weeks ago

That is because ; is considered to be the end of the line along with \n but ; is optional, so I am not sure if it is possible to introduce this without breaking changes.

Not sure if this eol is used at all, but you can see that ; was excluded from some expressions deliberately, check this

Perhaps we should find some workaround