Skip to content

Instantly share code, notes, and snippets.

@jvelezmagic
Created July 6, 2022 23:44
Show Gist options
  • Save jvelezmagic/0dd5df363089c9aa8ae7a523d1387923 to your computer and use it in GitHub Desktop.
Save jvelezmagic/0dd5df363089c9aa8ae7a523d1387923 to your computer and use it in GitHub Desktop.
render_md_as_rmd <- function(file, overwrite = TRUE, ...) {
file_name <- fs::path_ext_remove(file)
file_to_render <- fs::file_copy(
path = file,
new_path = fs::path(file_name, ext = "Rmd"),
overwrite = overwrite
)
tryCatch(
{
xfun::Rscript_call(
fun = rmarkdown::render,
args = list(input = file_to_render, ...)
)
},
finally = {
fs::file_delete(file_to_render)
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment