Commit 0d6efeb9 authored by Holger Brandl's avatar Holger Brandl
Browse files

prevent automatic yaml header

parent 8694b007
...@@ -25,18 +25,32 @@ Options: ...@@ -25,18 +25,32 @@ Options:
opts <- docopt(doc) opts <- docopt(doc)
r_script <- opts$r_script r_script <- opts$r_script
keep_markdown_files <- as.logical(opts$keep) keep_markdown_files <- as.logical(opts$keep)
if(keep_markdown_files){
print("keeping markdown files")
}
if(!file.exists(r_script)){ if(!file.exists(r_script)){
stop(paste("file does not exist\n", doc)) stop(paste("file does not exist\n", doc))
} }
require(plyr)
## postfix a default empty yaml header
tmpScript <- tempfile(fileext=".R")
metadata <- paste('\n',
'#\'---\n',
'#\'title: ""\n',
'#\'author: ""\n',
'#\'date: ""\n',
'#\'---\n'
, sep = "")
file.copy(r_script, tmpScript)
cat(metadata, file = tmpScript, append = TRUE)
#require(plyr)
require(knitr) require(knitr)
require(stringr) require(stringr)
...@@ -60,8 +74,9 @@ opts_chunk$set( ...@@ -60,8 +74,9 @@ opts_chunk$set(
width=200 width=200
) )
rmarkdown::render(input=r_script, browser()
output_format=rmarkdown::html_document(toc = opts$toc, keep_md=keep_markdown_files), rmarkdown::render(input=tmpScript,output_file=str_replace(basename(r_script), ".R", ".html"),
output_format=rmarkdown::html_document(toc = opts$toc, keep_md=T),
output_dir=getwd(), output_dir=getwd(),
output_options=list(toc="yes") output_options=list(toc="yes")
) )
......
## see ?compile_notebook
## [rmarkdown@rstudio](http://rmarkdown.rstudio.com/) ## [rmarkdown@rstudio](http://rmarkdown.rstudio.com/)
rmarkdown::render(input="/Users/brandl/Dropbox/projects/snippets/R/rmarkdown/test_doc.R", rmarkdown::render(input="/Users/brandl/Dropbox/projects/snippets/R/rmarkdown/test_doc.R",
output_format=rmarkdown::html_document(toc = T, keep_md=F), output_format=rmarkdown::html_document(toc = T, keep_md=T),
output_dir=getwd(), output_dir=getwd(),
output_options=list(toc="yes")) output_options=list(toc="yes"))
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment