linguist icon indicating copy to clipboard operation
linguist copied to clipboard

Add language: Mermaid Diagram Support

Open Yash-Singh1 opened this issue 2 years ago β€’ 7 comments

Language name

MermaidJS

URL of example repository

https://github.com/lotusnprod/lotus-processor/blob/f46c20768fa80e8fe6c438424323734f547f6163/docs/flowchart.mmd

URL of syntax highlighting grammar

WIP

Most popular extensions

.mmd

Detected language

N/A

Popularity

https://github.com/search?p=1&q=extension%3Ammd&type=Code (6K Results)

Yash-Singh1 avatar Sep 28 '21 22:09 Yash-Singh1

Please note, Linguist can only add support for syntax highlighting of the files (I'm not sure how useful that would be) assuming a grammar can be found. Rendering to show the images would need to be implemented elsewhere.

lildude avatar Sep 29 '21 07:09 lildude

assuming a grammar can be found

I am currently working on a text mate grammar, so I’ll create a PR after I am done with that.

Yash-Singh1 avatar Sep 29 '21 15:09 Yash-Singh1

I think https://github.com/bpruitt-goddard/vscode-mermaid-syntax-highlight should do the trick for syntax highlighting

lildude avatar Sep 01 '22 06:09 lildude

I've never seen this syntax before. Is !!import/deep a YAML thing?

repository:
  mermaid:
    patterns: !!import/deep
      - diagrams/

Doesn't look like a valid TextMate-compatible grammar to me. It might rely on a build-step or something…

Alhadis avatar Sep 01 '22 06:09 Alhadis

🀦 I completely missed that. Nope, that's not a YAML thing... it's a TypeScript module thing and yup, there's a build-step 😞

Ignore me 😁

lildude avatar Sep 01 '22 09:09 lildude

Want me to write one? I'm already halfway through taking apart Mermaid's own Monaco-based highlighter to see how it works. I've reduced it to a list of keywords and patterns, so smashing something together shouldn't be too difficult.

All I ask in return is that GitHub support Pikchr so we can use pic(1) on GitHub. 😁

EDIT: Wait, Mermaid is, like, 10 different syntaxes hiding under a trench-coat pretending to be a single language. I can write a grammar for it, but I probably won't be done in time for the next Linguist release. πŸ˜…

Alhadis avatar Sep 01 '22 09:09 Alhadis

Want me to write one? [...] EDIT: Wait, Mermaid is, like, 10 different syntaxes hiding under a trench-coat pretending to be a single language. I can write a grammar for it, but I probably won't be done in time for the next Linguist release. πŸ˜…

Go for it if you want the challenge and no rush. I thought it would be a quick addition when I found the grammar.

All I ask in return is that GitHub support Pikchr so we can use pic(1) on GitHub. 😁

Ask in the Product Feedback section of https://github.com/orgs/community/discussions/ and you never know, your wish may come true one day 😁

lildude avatar Sep 02 '22 10:09 lildude

Track progress here: https://github.com/Alhadis/language-mermaid

I'll submit a PR once I've finished splattering mermaids.

Alhadis avatar Oct 20 '22 23:10 Alhadis