mjbvz / vscode-markdown-mermaid

Adds Mermaid diagram and flowchart support to VS Code's builtin markdown preview
https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid
MIT License
657 stars 120 forks source link

Possible fix for parse failures with sequence diagrams #169

Closed swalterd closed 1 year ago

swalterd commented 1 year ago

Fix for an issue where sequence diagrams that end with a Message that has no text, just whitespace. The markdown parses in Github, but fails in VS Code preview pane. The trim() is removing the whitespace needed by Mermaid to parse the Message line and render the diagram. I have replaced it with a trim form the start of the string and just replacing trailing newlines only. I tried also just removing the trim() and could not see any issues but did not test all the other diagram types.

MD file I used to reproduce the error:

Use Cases

Sequence Diagram with text on last line

sequenceDiagram
    A->>B: This diagram parses
    B-->>A: text on last line

Sequence Diagram with spaces on last line

sequenceDiagram
    A->>B: This diagram fails with spaces on last line
    B-->>A: 

Everything below the parse failure does not render as diagram

graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
mjbvz commented 1 year ago

Thanks!