Created
December 15, 2013 05:18
-
-
Save 1beb/7969212 to your computer and use it in GitHub Desktop.
Header to slidify document
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
library(RGoogleDocs) | |
auth = getGoogleAuth("USERNAME", "PASSWORD") | |
con = getGoogleDocsConnection(auth) | |
write(file="tmp.html",getDocContent("DOCUMENT_NAME", con)) | |
system("python html2text.py tmp.html -g -b 0 -i 0 > tmp.rmd") | |
x <- readChar("tmp.rmd",nchar=100000000) | |
x <- gsub("<r-I(.[^>]*)>", "`r I\\1`", x) # find and convert inline <r-I()> code | |
x <- gsub("<r-(.[^>]*)>", "\n```{r \\1 } \n```", x) # find and convert r-chunks | |
x <- gsub(" ", "", x) # strange characters from html2text breaks slidify "---" | |
x <- gsub("^## |[^#]## ", "\n---\n\n## ", x) # adjust heading level 2 only | |
write(file="index.Rmd",x, append=TRUE) |
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
--- | |
title : Example Report | |
subtitle: Subtitle | |
job : Slidify 2013 | |
mode: standalone # {standalone, draft} | |
--- | |
{r init, echo=FALSE,message=FALSE, warning = FALSE, cache=FALSE} | |
opts_chunk$set(echo=FALSE, | |
message=FALSE, | |
comment="", | |
warning=FALSE, | |
results='asis', | |
fig.width=12, | |
fig.height=5, | |
cache=FALSE) | |
read_chunk('chunks.r') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment