From 9bfebc4d0fc6f75598083734b995eb484fffa512 Mon Sep 17 00:00:00 2001 From: Francois Michonneau Date: Wed, 22 Jun 2016 10:48:05 -0400 Subject: [PATCH 1/2] use .r instead of .source for code chunks --- bin/chunk-options.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/chunk-options.R b/bin/chunk-options.R index df52611..9765b7f 100644 --- a/bin/chunk-options.R +++ b/bin/chunk-options.R @@ -21,9 +21,9 @@ opts_chunk$set(tidy = FALSE, results = "markup", comment = NA, # The hooks below add html tags to the code chunks and their output so that they # are properly formatted when the site is built. hook_in <- function(x, options) { - stringr::str_c("\n\n~~~{.r}\n", + stringr::str_c("\n\n~~~\n", paste0(x, collapse="\n"), - "\n~~~\n{: .source}\n\n") + "\n~~~\n{: .r}\n\n") } hook_out <- function(x, options) { From ff37db08a1a0a1d913e763b93bcb15bc8bde2687 Mon Sep 17 00:00:00 2001 From: Francois Michonneau Date: Wed, 22 Jun 2016 10:48:53 -0400 Subject: [PATCH 2/2] remove extra line return in knitr output --- bin/chunk-options.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/chunk-options.R b/bin/chunk-options.R index 9765b7f..1890d32 100644 --- a/bin/chunk-options.R +++ b/bin/chunk-options.R @@ -27,12 +27,14 @@ hook_in <- function(x, options) { } hook_out <- function(x, options) { + x <- gsub("\n$", "", x) stringr::str_c("\n\n~~~\n", paste0(x, collapse="\n"), "\n~~~\n{: .output}\n\n") } hook_error <- function(x, options) { + x <- gsub("\n$", "", x) stringr::str_c("\n\n~~~\n", paste0(x, collapse="\n"), "\n~~~\n{: .error}\n\n")