Commit d7b0e852 authored by Raniere Silva's avatar Raniere Silva
Browse files

Merge pull request #284 from jdblischak/rmd-error-hook

Add support for error class for R Markdown generated lessons
parents a7c7240a 3396ab8e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ opts_chunk$set(tidy = FALSE, results = "markup", comment = NA,
               fig.align = "center", fig.path = "fig/")

# The hooks below add html tags to the code chunks and their output so that they
# are properly formatted when the site is built with jekyll.
# are properly formatted when the site is built.
hook_in <- function(x, options) {
  stringr::str_c("\n\n~~~{.r}\n",
                 paste0(x, collapse="\n"),
@@ -22,5 +22,11 @@ hook_out <- function(x, options) {
                 "\n~~~\n\n")
}

knit_hooks$set(source = hook_in, output = hook_out, warning = hook_out,
               error = hook_out, message = hook_out)
hook_error <- function(x, options) {
  stringr::str_c("\n\n~~~{.error}\n",
                 paste0(x, collapse="\n"),
                 "\n~~~\n\n")
}

knit_hooks$set(source = hook_in, output = hook_out, warning = hook_error,
               error = hook_error, message = hook_out)