Created
December 21, 2015 17:33
-
-
Save jwdink/2e1853e0dff254c131ac to your computer and use it in GitHub Desktop.
Take an .Rmd file and Generate a more generic .markdown file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generate_markdown_for_site <- function(path_to_rmd, path_to_knit_to) { | |
filename <- basename(path_to_rmd) | |
message("Setting working directory to ", path_to_rmd) | |
setwd(dirname(path_to_rmd)) | |
post_name <- sub("^([^.]*).*", "\\1", filename) | |
content <- readLines(paste0(post_name, ".Rmd")) | |
render_markdown(strict=TRUE) | |
opts_knit$set(out.format='markdown') | |
opts_knit$set(base.dir= paste0(path_to_knit_to, "/", post_name,"/") ) | |
opts_knit$set(base.url= paste0("/static/",post_name,"/") ) | |
opts_chunk$set(fig.height = 4, fig.width = 7, dpi = 96) | |
knit(text=content, output= paste0(path_to_knit_to, "/", post_name, ".markdown")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment