mermaid icon indicating copy to clipboard operation
mermaid copied to clipboard

State diagram: a problem with state names (state descriptions, the ":" operator)

Open Matthew0x opened this issue 2 years ago • 0 comments

Code Sample

stateDiagram-v2
state Cluster {
    state Node1: Node {
        state Pods1: Pods {
            A: Container A1
            B: Container B1
            C: Container C1
        }
    }
    state Node2: Node {
        state Pods2: Pods {
            A2: Container A2
            B2: Container B2
            C2: Container C2
        }
    }
}

or

stateDiagram-v2
state Cluster {
    state "Node" as Node1 {
        state "Pods" as Pods1 {
            A: Container A1
            B: Container B1
            C: Container C1
        }
    }
    state "Node" as Node2 {
        state "Pods" as Pods2 {
            A2: Container A2
            B2: Container B2
            C2: Container C2
        }
    }
}

(this one doesn't "compile" to begin with)

Describe the bug The expected behavior is for states to utilize the same syntax as the other components do. I can provide an ID for the components, e.g. the A, B, C or A2, B2, C2... then provide an alias or "name" for each using the ":" operator.

Following the official documentation at: https://github.com/mermaid-js/mermaid/blob/develop/docs/stateDiagram.md

I can read that: "Another way is by using the state keyword with a description as per below:

stateDiagram-v2 state "This is a state description" as s2 Another way to define a state with a description is to define the state id followed by a colon and the description:

stateDiagram-v2 s2 : This is a state description"

As provided (unless I am mistaken somehow) the expected syntax of ":" doesn't work when using "state" components. Neither the "as", nor the ":" seem to work.

Expected behavior Both operators should allow the user to write down the ID of the state (so without e.g. spaces) and then allow for writing down a specific name/alias that allows providing a name which accepts special characters, spaces etc.

This could be an indirect follow up of: https://github.com/mermaid-js/mermaid/issues/1342

I use the Mermaidv9.1.3 Live Editor

Matthew0x avatar Aug 04 '22 20:08 Matthew0x