Closed JosiahParry closed 1 year ago
@maelle: How can we make Mermaid work in pkgdown?
Related question: @krlmlr does this diagram work for you when you knit the vignette? It does not for me.
Interestingly DiagrammeR has a pkgdown website http://visualizers.co/diagrammer/ but no mermaid diagram sadly.
After experimenting a bit I discovered what works is using the Markdown of the diagram directly, I mean:
```{r echo = FALSE}
DiagrammeR::mermaid("graph TD
Import --> Tidy
Tidy --> Transform
Transform --> Visualize
Visualize --> Communicate
Visualize --> Model
Model -.-> Transform
")
![image](https://user-images.githubusercontent.com/8360597/219373818-06a6b5ef-d824-4b39-964a-c1d576131fd6.png)
I'm a bit surprised. I'm not sure whether this is pkgdown or DiagrammeR's doing however note I observe the same behavior (using the filename: the Markdown is printed in the doc; using the Markdown: the diagram appears) when _knitting_.
This works too:
```{r echo = FALSE}
text <- paste(
readLines("r4ds.mmd"),
collapse = "\n"
)
DiagrammeR::mermaid(text)
@krlmlr do you want me to make a PR with this "quick fix" or to investigate further/report to DiagrammeR?
Thanks. A quick fix is fine, we can even use something like
```{r echo = FALSE}
text <- "
<mermaid code>
"
DiagrammeR::mermaid(text)
Mermaid diagrams are not properly rendering on the pkgdown site. Here is a screencap from https://tibble.tidyverse.org/articles/formats.html