Mermaid Links with Use of Aliases or Custom Link Previews

Use case or problem

When creating Mermaid diagrams with internal links that have long names that I do not want to shorten in the vault, it would be nice to make use of these long links in the diagrams but have them display as shorter versions.

Proposed solution

If aliases and/or Custom Link Previews worked in the diagram, this would not be an issue.

Current workaround (optional)

In order to keep the longer note names in the vault but allow for having the shorter working note name internal links in Mermaid diagrams, I simply change the note name to the shorter version and set aliases for the longer version that I want to display in my vault. It is not ideal when retrofitting but it works pretty well. I can use the alias pipe link version with a mass search and replace so that all the long links that get shortened can be switched to the longer alias version.

Thanks.

8 Likes

I am looking forward to this feature too. I currently use zettel naming conventions in my vault, and the mermaid flowchart makes no sense if I can’t use alias to link notes in them.

1 Like

In addition, it is also gonna be extremely useful if we can link the text on mermaid links to notes in the vault too.

1 Like

Great idea.

That may even warrant a separate feature request if you are up for making it.

Thanks.

I figured out how to do this using the Obsidian URL for the note.

Here is an example from my notes

flowchart LR;  

content[Content]
fleet[Fleeting Note]
lit[Literature Note]
perm1[Permanent Note]
perm2[Permanent Note]
perm3[Permanent Note]
perm4[Permanent Note]

content-->|Take notes|lit;
fleet-->|processed ideas|perm1;
lit-->|processed ideas|perm1;
perm1-->|Link to|perm2;
perm1-->|Link to|perm3;
perm1-->|Link to|perm4;

 
click fleet "obsidian://open?vault=Smart%20Notes%20Presentation&file=Fleeting%20Notes%20are%20brief%20reminders%20of%20your%20thinking" _blank
click lit "obsidian://open?vault=Smart%20Notes%20Presentation&file=Literature%20Notes%20help%20capture%20ideas%20and%20concepts%20while%20consuming%20content" _blank
click perm1 "obsidian://open?vault=Smart%20Notes%20Presentation&file=A%20Permanent%20note%20contains%20a%20single%20idea%20that%20is%20the%20result%20of%20your%20thinking%20on%20what%20you%20have%20learned" _blank
click perm2 "obsidian://open?vault=Smart%20Notes%20Presentation&file=A%20Permanent%20note%20contains%20a%20single%20idea%20that%20is%20the%20result%20of%20your%20thinking%20on%20what%20you%20have%20learned" _blank
click perm3 "obsidian://open?vault=Smart%20Notes%20Presentation&file=A%20Permanent%20note%20contains%20a%20single%20idea%20that%20is%20the%20result%20of%20your%20thinking%20on%20what%20you%20have%20learned" _blank

I figured this out by looking at the Interaction section of the Mermaid Documentation.

6 Likes

you should not have to use the full obsidian link for this to work though. The pipe format should have worked right away as it’s proper mermaid syntax.

Use case or problem

Even though we can make each node in Mermaid Diagrams an internal link to our note since 0.9.21, we could only use the name of our notes directly as the name of the node in Mermaid. However, since I adopted the Zettelkestan systems in my vault and named each note with the timestamp of its creation (such as “2021010711487”), it makes no sense unless I can use the alias of my notes when I create internal links in Mermaid.

In addition, as I was organizing my notes, I found it is gonna be a very useful feature if we could link the text on an edge in Mermaid to a note in the vault too. For example, in a graph representing how to make carboxylic acids from other functional groups, each nodes can represent a distinct functional group and link to its description, while each text on the edge can represent a method and link to its specific procedure and protocols.

Proposed solution

  1. Use alias when creating internal links in Mermaid
  2. Create internal links on both Mermaid nodes and texts on edges.

Current workaround

I currently didn’t find any workaround to my problem.

Related feature requests

11 Likes

+1 bump

1 Like

+1 bump

an example of this is;

    OBJECT[Full name of note for OBJECT]--> OBJECTIST[Full name of note for OBJECTLIST];

where it really should support the pipe notation to allow shorter names:

    OBJECT[Full name of note for OBJECT|OBJECT]--> OBJECTIST[Full name of note for OBJECTLIST|OBJECTLIST];

where only the shorter names are shown in the diagram but the link takes you to the note correctly.