I would like to display R code similar to markdown code, e.g. r_code
. Is this possible with mermaid?
MWE:
---
format: html
---
```{mermaid}
%%{init: {'themeVariables': { 'edgeLabelBackground': 'white'}}}%%
flowchart TD
X1(First) --> X2(own_r_function)
```
My attempt:
---
format: html
---
```{mermaid}
%%{init: {'themeVariables': { 'edgeLabelBackground': 'white'}}}%%
flowchart TD
X1(First) --> X2(`own_r_function`)
```
One possible approach could be using a css class to mimic the code format style of Quarto for text wrapped within span
tag. And note that, code
tag also works.
---
format: html
---
```{=html}
<style>
.codeStyle span:not(.nodeLabel) {
font-family: monospace;
font-size: 0.8em;
color: #9753b8 !important;
background-color: #f6f6f6;
padding: 0.2em;
}
</style>
```
```{mermaid}
%%{init: {'themeVariables': { 'edgeLabelBackground': 'white'}}}%%
flowchart TD
X1(First) --> X2(This is some text <span>own_r_function</span> in custom styled code format using span tag)
class X2 codeStyle
X2 --> X3(This is some text <code>own_r_function</code> in custom styled code format using code tag)
```