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\n', options$params.src)
  } else '    ```\n'
})

Can I write the three backticks in the output?

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 May 20, 2021, 5:08 p.m.