Last active
August 29, 2015 14:25
-
-
Save klainfo/a9485a5faeb74c8bca33 to your computer and use it in GitHub Desktop.
Put in the Rmd directory and run ./render_post.R <file.Rmd>
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
#!/usr/bin/env Rscript | |
# Reference: http://jfisher-usgs.github.io/r/2012/07/03/knitr-jekyll/ | |
input <- commandArgs(trailingOnly = TRUE) | |
KnitPost <- function(input, base.url = "/") { | |
require(knitr) | |
opts_knit$set(base.url = base.url) | |
fig.path <- paste0("../figs/", sub(".Rmd$", "", basename(input)), "/") | |
opts_chunk$set(fig.path = fig.path) | |
opts_chunk$set(fig.cap = "center") | |
render_jekyll() | |
print(paste0("../_posts/", sub(".Rmd$", "", basename(input)), ".md")) | |
knit(input, output = paste0("../_posts/", sub(".Rmd$", "", basename(input)), ".md"), envir = parent.frame()) | |
} | |
KnitPost(input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment