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

Empty message in mermaid sequence diagram not working #1823

Open
ls-bit opened this issue Feb 5, 2025 · 2 comments
Open

Empty message in mermaid sequence diagram not working #1823

ls-bit opened this issue Feb 5, 2025 · 2 comments

Comments

@ls-bit
Copy link

ls-bit commented Feb 5, 2025

Mermaid allows sequence diagrams to contain empty messages. For an empty message just a whitespace is added instead of text. It should render a line without text. GitHub handles this correctly:

sequenceDiagram
    Alice->>John: Hello
    John-->>Alice: 
Loading

Kroki throws an error for the same diagram:

Error 400: Error: Syntax error in graph: Parse error on line 5: ...! John-->>-Alice: ----------------------^ Expecting 'NEWLINE', 'AS', ',', 'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'BIDIRECTIONAL_SOLID_ARROW', 'DOTTED_ARROW', 'BIDIRECTIONAL_DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT', 'TXT', got 'INVALID' Error: Parse error on line 5: ...! John-->>-Alice: ----------------------^ Expecting 'NEWLINE', 'AS', ',', 'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'BIDIRECTIONAL_SOLID_ARROW', 'DOTTED_ARROW', 'BIDIRECTIONAL_DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT', 'TXT', got 'INVALID' at Ot.parseError (file:///usr/local/kroki/assets/mermaid/chunks/mermaid.esm.min/sequenceDiagram-7SUASMRF.mjs:1:14208) at Ot.parse (file:///usr/local/kroki/assets/mermaid/chunks/mermaid.esm.min/sequenceDiagram-7SUASMRF.mjs:3:174) at Diagram.fromText (file:///usr/local/kroki/assets/mermaid/mermaid.esm.min.mjs:3:253) at async Object.render (file:///usr/local/kroki/assets/mermaid/mermaid.esm.min.mjs:10:1164)

https://kroki.io/mermaid/svg/eNorTi0sTc1LTnXJTEwvSszlUgACx5zM5FRdOzuv_Iw8KwWP1JycfLA4iK8LFAfLWykAAEB5EiQ=

If the empty message is not the last line it also works in Kroki:

sequenceDiagram
    Alice->>John: Hello
    John-->>Alice: 
    John->>Alice: Hello
Loading

https://kroki.io/mermaid/svg/eNorTi0sTc1LTnXJTEwvSszlUgACx5zM5FRdOzuv_Iw8KwWP1JycfLA4iK8LFAfLWylgE0sBAPLhF68=

Maybe this happens due to input being trimmed somewhere.

@ggrossetie
Copy link
Member

It seems to be related to how we encode/decode the diagram. It's working fine if I send the diagram using a POST request: https://docs.kroki.io/kroki/setup/usage/

@ggrossetie
Copy link
Member

One way to workaround this limitation is to add an empty comment (in order to preserve the trailing spaces):

sequenceDiagram
    Alice->>John: Hello
    John-->>Alice: 
%% 

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

2 participants