joeyespo / grip

Preview GitHub README.md files locally before committing them.
MIT License
6.45k stars 423 forks source link

Add mermaid diagrams support through javascript #389

Open nikolavp opened 2 months ago

nikolavp commented 2 months ago

This is the best option that I could find for this. Another way would be to shellout to the mermaid-cli but that seems too heavyweight and needs yet another cli to be installed on the machine. Where the pure javascript library is just portable.

What this does is that it reverses the highlighting done github API and then it runs the mermaid javascript library on top of the pre tags that are created.

The only downside that I can see is that there is now a dependency on the mermaid javascript library in the template. There might be ways to get around this by loading the file dynamically but that seems far too complex for my taste.

This should hopefully fix https://github.com/joeyespo/grip/issues/355