How to nest fenced code chunks?

I often need to store Rmarkdown code chunks in Logseq. These are fenced using the same ``` chunk delimiters as Logseq. My desired outcome is for the Rmarkdown chunk rendered by Logseq to display backticks, so as to enable direct copying to other apps (Rstudio).

Nesting delimiters seems like a logical way forward but Logseq (and forums!) will garble nested backticks:

Screenshot_2022-10-13_15-00-02

Renders as…

```{r chunk-name option="value"} # Innermost delimiter for Rmarkdown code chunk
code
1 Like

Replying to myself for the benefit of others… there are two workarounds:

  1. Store the code chunk without back-ticks and add these in the other environment (in my case that was RStudio)
  2. Use fewer back-ticks in the inner most code chunk. This has the disadvantage of needing manual repair in the other environment in order to be recognised as a code chunk.
```
``{r chunk-name option="value"}
``
```