tidyverse / tibble

A modern re-imagining of the data frame
https://tibble.tidyverse.org/
Other
671 stars 130 forks source link

Diagrams are not rendering on pkgdown site #1497

Closed JosiahParry closed 1 year ago

JosiahParry commented 1 year ago

Mermaid diagrams are not properly rendering on the pkgdown site. Here is a screencap from https://tibble.tidyverse.org/articles/formats.html

image
krlmlr commented 1 year ago

@maelle: How can we make Mermaid work in pkgdown?

maelle commented 1 year ago

Related question: @krlmlr does this diagram work for you when you knit the vignette? It does not for me.

maelle commented 1 year ago

Interestingly DiagrammeR has a pkgdown website http://visualizers.co/diagrammer/ but no mermaid diagram sadly.

maelle commented 1 year ago

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_.
maelle commented 1 year ago

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?
krlmlr commented 1 year ago

Thanks. A quick fix is fine, we can even use something like

```{r echo = FALSE}
text <- "
<mermaid code>
"
DiagrammeR::mermaid(text)