Skip to content

Instantly share code, notes, and snippets.

@sfirke
Last active May 22, 2020 17:49
Show Gist options
  • Save sfirke/a75ed7906fa2b773096eec41e6979d35 to your computer and use it in GitHub Desktop.
Save sfirke/a75ed7906fa2b773096eec41e6979d35 to your computer and use it in GitHub Desktop.
Function to build R package vignettes, retaining both .md and .Rmd
# From https://stackoverflow.com/questions/45575971/compile-a-vignette-using-devtoolsbuild-vignette-so-that-md-is-kept-in-the-v
# Usage: render_keep_md("tabyls")
render_keep_md <- function(vignette_name){
# added the "encoding" argument to get the oe character passed through correctly to the resulting .Md
rmarkdown::render(paste0("./vignettes/",vignette_name, ".Rmd"), clean=FALSE, encoding = 'UTF-8')
files_to_remove = paste0("./vignettes/",vignette_name, c(".html",".knit.md",".utf8.md"))
lapply(files_to_remove, file.remove)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment