Implement D2 syntax highlighting

D2 is a language for diagrams.

See https://d2lang.com/

Looks like this:

image

It's quite simple to use but while writing this I realized it's pretty complex with a lot of edge cases. Many things depend on active context. I didn't implement everything context-aware just some things that seemed worth it.

Everything I checked seems to work fine, but I noticed 2 issues:

  1. Empty brackets fold parent...
parent: {
  child: {
  }
  child2
}

If you click to fold child it will collapse whole parent. This seems to be engine bug because that also happens for other languages. If you add even single newline before } then it works correctly.

  1. Markdown embedding doesn't terminate if last line is a list
item: |md
* list
|

It doesn't recognize that | should terminate Markdown. If I add newline like this

item: |md
* list

|

then it works fine. I think this is issue with Markdown highlighter. Other text or header doesn't have such issue.

Merge request reports

Loading
Loading