Mermaid Diagrams - Why isn't simple math rendering?

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I am trying to get exponents and parentheses to render in Obsidian Mermaid diagram, below.

graph TD
    A[Problem] --> B{Is it a data organization problem?}
    B -->|Yes| C{Is data order important?}
    B -->|No| D{Does it involve finding specific items?}
    
    C -->|Yes| E["<b>Sorting Algorithms</b>
				    <u>Comparison Based</u>
				    Bubble Sort <math><mi>= O(n^2)</mi></math>
				    Selection Sort = O()
				    Insertion Sort = O()
				    Merge Sort = O() #DivideAndConquer
				    Quick Sort = O() #DivideAndConquer
				    Heap Sort = O()
				    "]

Things I have tried

Search terms: Latex, Katex, Mermaid

To get the parentheses to render, I wrap the text in quotation marks. That’s working.

To get the exponents to render, well, I don’t know what to do. But it appears from the following discussion that something should work? I haven’t yet figured out what works, though. I’ve tried $, $$ and html tags like and . Nothing I’ve tried has worked yet.

Discussion: Adding LaTeX math support via Katex · Issue #2776 · mermaid-js/mermaid · GitHub

1 Like

I solved the problem by installing the Mehrmaid plugin, updated my codeblocks to reference mehrmaid instead of mermaid, and used single $ within double quote pairs to get Markdown/Latex to render correctly. Very pleased with this plugin! Thanks to the maker.

1 Like

That is an excellent plugin! Wish i had known about it sooner.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.