tests/testthat/examples/knitr-examples/062-chunk-wrapper.md

Write the chunk wrapper to the output

All chunk options are stored in options$params.src.

library(knitr)
knit_hooks$set(wrapper = function(before, options, envir) {
    if (before) {
        sprintf("    ```{r %s}\n", options$params.src)
    } else "    ```\n"
})

Can I write the three backticks in the output?

```{r test_label, wrapper=TRUE, eval=FALSE}
1 + 1
plot(1)
```

By default the chunk wrapper will not show up, e.g.

rnorm(100)
y ~ x


Try the parsermd package in your browser

Any scripts or data that you put into this service are public.

parsermd documentation built on Aug. 21, 2025, 5:27 p.m.