Skip to content

Instantly share code, notes, and snippets.

@jhrcook
Last active March 11, 2019 02:03
Show Gist options
  • Save jhrcook/9838880c4721e0d70520a934104e3ec0 to your computer and use it in GitHub Desktop.
Save jhrcook/9838880c4721e0d70520a934104e3ec0 to your computer and use it in GitHub Desktop.
Rmarkdown triple-back quote escape
You can insert a code chunk within a code chunk in Rmarkdown as shown here. This code chunk was used in my bookdown book "Package as Analysis" to show a SublimeText3 snippet that itself inserts a code chunk
````html
<snippet>
<content><![CDATA[
`r ''````{r ${1:chunk_name}}
$0
```
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>rchunk</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.html.markdown.multimarkdown, text.html.markdown</scope>
<description>create a Rmd code chunk</description>
</snippet>
````
More simply:
````html
outside of in-chunk code chunk
`r ''````{r ${1:chunk_name}}
inside of in-chunk code chunk
```
back outside of in-chunk code chunk
````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment