I'm getting an error message when I try inserting a Mermaid code chunk into the RStudio IDE in a Quarto document. It's my understanding that Quarto has built-in support for Mermaid diagrams and it's built into the current version of RStudio IDE (I'm using the windows community version 2023.09.1 build 494 on an up-to-date Windows 11). Mermaid is one of the code chunk options.
The code chunk:
{mermaid}
graph LR
A-->B
produces the error message "'mermaid' is not recognized as an internal or external command, operable program or batch file."
FWIW the run code chunk icons do not appear in the upper right corner of the code chunk
I tried installing and loading DiagrammeR, which didn't help, although inserting the following R code chunk was an effective workaround.
{r}
library(DiagrammeR)
mermaid("
graph LR
A-->B
")
Is there an extension I'm supposed to install to get Mermaid to work?
---
title: "Mermaid"
author: "jrkrideau"
date: "`r Sys.Date()`"
date-format: iso
number-sections: true
format: html
---
```{r libraries}
#| label: setup
#| include: false
#| eval: true
library(DiagrammeR)
```
“Arma virumque cano, Troiae qui primus ab oris Italiam, fato profugus, Laviniaque venit litora, multum ille et terris iactatus et alto vi superum saevae memorem Iunonis ob iram;”
```{r}
#| echo: false
mermaid("
graph LR
A-->B
")
```
@lloydbrodsky what is your complete document ? This works ok
---
title: "Test"
format: html
keep-md: true
---
```{mermaid}
graph LR
A-->B
```
This is expected as the IDE does not know how to run those chunks, they are only evaluated in rendered and preview mode using Quarto but not in Notebook mode.
@jrkrideau Thanks for looking at this. As I mentioned the problem was that the IDE doesn't evaluate and render Mermaid chunks in Visual (preview) mode. In retrospect I assumed that if a particular chunk type (R, Mermaid, etc) was in the dropdown list (initiated by a '/') then it would be dynamically rendered. This is clearly wrong and the workaround is to write it up as an R chunk -- with diagrammeR for mermaid.
It occurs to me it might be worthwhile to give some visual indication someplace (such as, say, an asterisk on that dropdown or in documentation) on which are rendered dynamically and which not.