Skip to content
Snippets Groups Projects
Commit 79310cc3 authored by Holger Brandl's avatar Holger Brandl
Browse files

added code hide button

parent 40432362
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,11 @@ file.copy(r_script, tmpScript)
cat(metadata, file = tmpScript, append = TRUE)
jsAddons <- tempfile(fileext=".js")
#cat("<script src='https://raw.githubusercontent.com/holgerbrandl/datautils/master/R/rendr/toggle_code_sections.js' type='application/javascript'></script>", file=jsAddons)
cat("<script src='https://code.jquery.com/jquery-2.1.4.min.js' type='application/javascript'></script>", file=jsAddons)
cat("<script src='http://cdn.rawgit.com/holgerbrandl/datautils/master/R/rendr/toggle_code_sections.js' type='application/javascript'></script>", file=jsAddons, append=T)
#require(plyr)
require(knitr)
require(stringr)
......@@ -74,9 +79,8 @@ opts_chunk$set(
width=200
)
browser()
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_format=rmarkdown::html_document(toc = opts$toc, keep_md=T, pandoc_args=paste("--include-in-header=", tempfile)),
output_dir=getwd(),
output_options=list(toc="yes")
)
......
......@@ -4,6 +4,14 @@
## [rmarkdown@rstudio](http://rmarkdown.rstudio.com/)
rmarkdown::render(input="/Users/brandl/Dropbox/projects/snippets/R/rmarkdown/test_doc.R",
output_format=rmarkdown::html_document(toc = T, keep_md=T),
output_format=rmarkdown::html_document(toc = T, keep_md=T, pandoc_args="--include-in-header=/var/folders/n4/vdks_qcx54db16yj2lg665lm0000gp/T//RtmpysrYQU/file202b60316743.js"),
# output_format=rmarkdown::html_document(toc = T, keep_md=T, pandoc_args="-H /var/folders/n4/vdks_qcx54db16yj2lg665lm0000gp/T//RtmpysrYQU/file202b60316743.js"),
# output_format=rmarkdown::html_document(toc = T, keep_md=T, pandoc_args="--include-in-header=/Users/brandl/test.js", self_contained=F),
output_dir=getwd(),
output_options=list(toc="yes"))
\ No newline at end of file
output_options=list(toc="yes"))
#' # Pandoc
#' All options are listed at http://pandoc.org/README.html and can be used as "pandoc_args" in html_document
......@@ -4,8 +4,12 @@ $(document).ready(function () {
codeElements.filter("pre").before($('<button class="toggle_code">Show Code</button>'));
codeElements.filter("pre").hide()
$(".toggle_code").on("click", function () {
$(this).next().slideToggle()
var codeToggleButtons = $(".toggle_code");
codeToggleButtons.css("font-size", "70%");
codeToggleButtons.on("click", function () {
$(this).next().slideToggle();
if($(this).text()=="Hide Code"){
$(this).text("Show code")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment