bpruitt-goddard / vscode-mermaid-syntax-highlight

Markdown syntax support for the Mermaid charting language
MIT License
98 stars 37 forks source link

syntax error when add note to statediagram #55

Closed heartacker closed 2 years ago

heartacker commented 3 years ago
stateDiagram-v2

state github_gitlab{
Local0-->git_Server:push
git_Server-->Local0:pull
}
note left of github_gitlab: 最常见\n 的方式
state gerrit{
gerrit_server-->git_server:commit
Local1-->gerrit_server:push with review
git_server-->Local1:pull/sync
}

image

heartacker commented 3 years ago

hi,anybody could fix this?

bpruitt-goddard commented 3 years ago

The syntax is expecting a space before the colon. Adding this space will allow the highlighting to continue working on the rest of the diagram. However, there is a bug with the backslash character not being treated as part of the note, hence the rest of the line still failing syntax highlighting. I'll work on a fix for this:

note left of github_gitlab : 最常见\n 的方式

image

Additionally, you'll see more syntax highlighting work by adding spacing around the arrows/curly brackets:

stateDiagram-v2

  state github_gitlab {
  Local0 --> git_Server:push
  git_Server --> Local0:pull
  }
  note left of github_gitlab : 最常见\n 的方式
  state gerrit {
    gerrit_server --> git_server:commit
    Local1 --> gerrit_server:push with review
    git_server --> Local1:pull/sync
  }

image

The reason for the spacing around the arrows is so that the dash characters can be used in the entities on either side of them - it is essentially a tradeoff between using a space or dash character in the entities.

bpruitt-goddard commented 2 years ago

This will go out with the next release (1.4.2). With the fix I'm seeing the diagram highlight properly:

image