Mermaid diagram render support

It would be nice if you do the Mermaid diagram support.


Now only the display of the code works, but I would like the rendering itself (Obsidian has this support):

image

https://mermaid-js.github.io/mermaid/#/

This is a great idea! Would love this functionality

1 Like

The mermaid diagram looks cool! Since the plugin system is under heavy development, I think this might be a good idea for a testing plugin.

What do you think? @Charlie

2 Likes

https://diagrams.net would be great too!

Mermaid is gaining popularity, even GitHub have it’s support in the roadmap

Mermaid doesn’t do a lot of diagram formats. Unlike plantuml/planttext it doesn’t allow graph viz diagrams. Joplin has a PlantUML plugin and I can use this:

bgcolor="purple:pink" label="Scrum App" fontcolor="white"
  subgraph cluster1 {fillcolor="blue:cyan" label="Press" fontcolor="white" style="filled" gradientangle="270"
		node [group=g1 packmode=array_c3 shape=box fillcolor="red:yellow" style="filled" width="80%" gradientangle=90]
		Undone;
		node [group=g2 packmode=array_c3 shape=box fillcolor="red:yellow" style="filled" gradientangle=90]
		"Done Done";
		node [group=g3 packmode=array_c3 shape=box fillcolor="red:yellow" style="filled" gradientangle=90]
		Done;
	}
edge [style=invis];
  Done -> "Done Done"
  "Done Done" -> Undone
}

At least diagrams.net does free format diagrams.

The incredible @hkgnp has made a plugin adding mermaid support to Logseq. It’s on the marketplace and you can check it out here as well:

2 Likes

I am trying to use the plugin but if I fork a path, it won’t render. It just says:
There is an error with your mermaid syntax. Please rectify and render again.

Can you share your mermaid syntax here?

1 Like

graph TD
A(Coffee machine
not working) → B{Machine has power?}
B -->|No| H(Plug in and turn on)
B -->|Yes| C{Out of beans or water?} -->|Yes| G(Refill beans and water)
C -->|No| D{Filter warning?} -->|Yes| I(Replace or clean filter)
D -->|No| F(Send for repair)

Your syntax looks like may have some typos. Please see here:

flowchart TD
A(Coffee machine not working) --> B{Machine has power?}
B -->|No| H(Plug in and turn on)
B -->|Yes| C{Out of beans or water?} -->|Yes| G(Refill beans and water)
C -->|No| D{Filter warning?} -->|Yes| I(Replace or clean filter)
D -->|No| F(Send for repair)

Does mermaid.ink upload/store our diagrams on someone’s servers? I’m hesitant to use this for work because of potential data leakage.

1 Like

I could easily be misreading/skimming the source code.

However it looks to me like the code use the Koa javascript library to do the work of a “web server”. I don’t see any place where the information is sent “off host”.

But you could install the plugin. then unplug from the network and try it out. If it fails… then check your network logs to see what went wrong. :slight_smile: Just a thought.

mermaid.ink can be installed locally on your computer and just run as a local server. Just follow the instructions here.

For more detailed instructions on using it with the logseq-mermaid-plugin, you can find it here.

Could render it like obsidian as a local element, not just a picture?
(want use Wikilink in mermaid like it,)

  • Such a mermaid is much more useful than an existing graphic view (if the mermaid can be automatically hung under the page like Backlink, the page relationship will be more convenient), there can be a local mermaid graph (each code block you write), and the overall graph (if necessary, based on the logical integration of the big picture,),
  • This idea is like the mermaid x breadcrumbs x backlink to improve the existing Backlink, because the existing BackLink is more like a label and cannot explain the relationship between pages.
1 Like

While I like the creativity of the plugin… I really wish this feature could be “tightly packaged” into logseq. ( without the need to run a local “web server”. )

Meaning is there anyway this functionality could be incorporated into the base with maybe just a JavaScript render? Instead of a full local NodJS web server install running on a local port?

Is there a path to get a plugin “pulled in” to the core project?

1 Like

Try the new fenced code plus plugin which allows you to render mermaid locally

Hi @Aryan, thanks for the tip, but I can’t find any documentation on how to use fenced code plus. Could you give an example?

You can install the fenced code plus plugin in the marketplace.

Just create a regular markdown code block. Set the language to mermaid. That’s it :slight_smile: