Skip to content

Add mermaid diagrams support through javascript - #389

Open
nikolavp wants to merge 2 commits into
joeyespo:masterfrom
nikolavp:add-mermaid-support
Open

Add mermaid diagrams support through javascript#389
nikolavp wants to merge 2 commits into
joeyespo:masterfrom
nikolavp:add-mermaid-support

Conversation

@nikolavp

@nikolavp nikolavp commented Jul 9, 2024

Copy link
Copy Markdown

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 #355

nikolavp added 2 commits July 10, 2024 00:10
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.
@erik-nilcoast

Copy link
Copy Markdown

I just stumbled on this. I think I'll use your branch :)

@simonwex

simonwex commented Mar 2, 2025

Copy link
Copy Markdown

@joeyespo any thoughts on merging this?

@adrianlzt

Copy link
Copy Markdown

Fast way to use this branch:

uvx --from git+https://github.com/nikolavp/grip@add-mermaid-support grip index.md

@guo-sj

guo-sj commented Apr 29, 2025

Copy link
Copy Markdown

I'm a novice in javascript and I want to know that how to make this pr effect on my readme.md.
This is my readme.md:

---
title: Memento Pattern
---
classDiagram
    direction LR
    Memento <.. Originator
    Caretaker o-- Memento : memento
    class Originator{
        -state
        +restoreMemento(Memento m)
        +createMemento()
    }
    class Memento{
        -state
        +getState()
        +setState()
    }
    class Caretaker{
        -Memento memento
    }

I run pip install -e . in the repo and I just get this:
image

Any help will be appreciate.

@guo-sj

guo-sj commented May 11, 2025

Copy link
Copy Markdown

I'm a novice in javascript and I want to know that how to make this pr effect on my readme.md. This is my readme.md:

---
title: Memento Pattern
---
classDiagram
    direction LR
    Memento <.. Originator
    Caretaker o-- Memento : memento
    class Originator{
        -state
        +restoreMemento(Memento m)
        +createMemento()
    }
    class Memento{
        -state
        +getState()
        +setState()
    }
    class Caretaker{
        -Memento memento
    }

I run pip install -e . in the repo and I just get this: image

Any help will be appreciate.

I finally figured it out, use the following command to apply this pr:

git clone https://github.com/joeyespo/grip.git
cd grip
git fetch origin pull/389/head:mermaid-support
git checkout mermaid-support

then uninstall the old version and install the new version of grip:

pip uninstall grip
pip install -e .  # execute in grip directory

@unhappychoice

Copy link
Copy Markdown

For anyone looking for Mermaid support right now, mdts already supports all Mermaid diagrams out of the box without any complex workarounds.

Just run npx mdts and your flowcharts, sequence diagrams, etc. will render perfectly.

https://github.com/unhappychoice/mdts

Might be helpful while waiting for this PR to be reviewed and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: mermaid diagram rendering

6 participants