### 7. Diagrams and Visualizations
To further illustrate these concepts, let's use a diagram to compare the growth rates of different complexity notations:
```mermaid
graph TD
A[O(1)] --> B[O(log n)]
B --> C[O(n)]
C --> D[O(n log n)]
D --> E[O(n^2)]
E --> F[O(2^n)]
```
But this works:
```mermaid
graph TD
A[O#40;1#41;] --> B[O#40;log n#41;]
B --> C[O#40;n#41;]
C --> D[O#40;n log n#41;]
D --> E[O#40;n^2#41;]
E --> F[O#40;2^n#41;]
```
And few other characters, such as HashMap~String, Integer~ instead of HashMap<String, Integer>
Maybe I can create custom shortcode?
I am not really sure we need it as a feature: indeed it is issue at Mermaid side; GitHub also shows such diagrams incorrectly unless I explicitly use #40;#41 etc
Then either the Mermaid team should fix this, or you should modify layouts/_default/_markup/render-codeblock-mermaid.html to do some sort of search/replace. For example:
Thank you for the snippet!
Yes it may break some other diagrams; I just thought, after initial post, best if Mermaid team fixes that. Diagrams either break or not break at Hugo and in the GitHub (which integrates Mermaid same way as Hugo does, without “workarounds”), better if Repo shows same issues as Hugo
In production, I use different theme, GitHub - hbstack/mermaid: HB Mermaid Module (and it has same issue; I believe all existing Hugo-Mermaid implementations have same issue)
Here, I created absolute minimalistic setup to isolate the issue. I am wondering how to fix it:
I even created plain minimalistic HTML file which you can open in the browser, followint Mermaid instructions, and it shows error. Somehow GitHub found a way to fix this issue.
This test site seem to work fine using the template code above. It contains the two examples from this topic, as well as some examples from https://mermaid.js.org/syntax/examples.html.
git clone --single-branch -b hugo-forum-topic-52506 https://github.com/jmooring/hugo-testing hugo-forum-topic-52506
cd hugo-forum-topic-52506
hugo server