bpruitt-goddard / vscode-mermaid-syntax-highlight

Markdown syntax support for the Mermaid charting language
MIT License
92 stars 36 forks source link

Add Graph Multiline Text Support #88

Closed bpruitt-goddard closed 1 year ago

bpruitt-goddard commented 1 year ago

This is to add multiline support called out in #64.

In order to add multiline support. the graph entities and graph links needed to be re-structured. Previously, the graph links were dependent upon an entity first existing (hanging off of begin/end patterns identifying an entity). But multiline graph links now required multiple graph link patterns based upon whether the graph link spanned one line or multiple. If the graph link was a multiline text version it needed a different end pattern than a single line version.

With the previous entity structure, each entity pattern would need all of these graph patterns:

But this could still cause problems for chained links such as:

   A -- text --> B -- text2 --> C

Instead, entities and graph links needed to be separated so that they can highlight independently and not explode the complexity (and duplication) of the patterns. The new structure defines them separately allowing for the above to work:

The tradeoff is that this now can highlight improper statements such as where the initial entity is missing:

   -- text --> B -- text2 --> C

But this will reveal itself in whatever renderer the user is using to view the diagrams. And the syntax highlighter shouldn't necessarily be responsible for asserting the syntax is correct.