Skip to content

Commit

Permalink
Revert "fixed knit_child when knitting chunks with blocks that produc…
Browse files Browse the repository at this point in the history
…e multiple ..."
  • Loading branch information
yihui committed Sep 1, 2014
1 parent 9073d08 commit 2c4f1f9
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,6 @@ auto_format = function(ext) {
#'
#' # comment out the child doc by \Sexpr{knit_child('child-doc.Rnw', eval = FALSE)}
knit_child = function(..., options = NULL, envir = knit_global()) {
old <- remove_all_hooks()
on.exit(restore_hooks(old), add = TRUE)
knit_child_unwrapped(..., options= options, envir = envir)
}

knit_child_unwrapped = function(..., options = NULL, envir = knit_global()) {
child = child_mode()
opts_knit$set(child = TRUE) # yes, in child mode now
on.exit(opts_knit$set(child = child)) # restore child status
Expand All @@ -380,26 +374,6 @@ knit_child_unwrapped = function(..., options = NULL, envir = knit_global()) {
paste(c('', res), collapse = '\n')
}

get_hook_names <- function() {
ls(.userHooksEnv, all.names = TRUE)
}

remove_all_hooks <- function() {
hook_names <- get_hook_names()
old <- list()
for (hook_name in hook_names) {
old[[hook_name]] <- getHook(hook_name)
setHook(hook_name, NULL, action = "replace")
}
old
}

restore_hooks <- function(hooks) {
for (hook_name in names(hooks)) {
setHook(hook_name, hooks[[hook_name]], action = "replace")
}
}

#' Exit knitting early
#'
#' Sometimes we may want to exit the knitting process early, and completely
Expand Down

0 comments on commit 2c4f1f9

Please sign in to comment.