Skip to content

Commit

Permalink
Merge pull request #835 from yihui/revert-831-knit_child_fix
Browse files Browse the repository at this point in the history
Reverts #831 (an inappropriate fix)
  • Loading branch information
yihui committed Sep 1, 2014
2 parents 9073d08 + 2c4f1f9 commit 4bfec9a
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 4bfec9a

Please sign in to comment.