Skip to content

Commit

Permalink
Avoid using evaluate internals (#2353)
Browse files Browse the repository at this point in the history
In a few years, once this code is widespread in installed knitr, this will allow us to make some simplifications to evaluate
  • Loading branch information
hadley committed Jul 8, 2024
1 parent 83edf48 commit 389382f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,9 @@ knit_print.knit_asis_url = function(x, ...) x

#' @rdname knit_print
#' @export
normal_print = default_handlers$value
formals(normal_print) = alist(x = , ... = )
normal_print = function(x, ...) {
if (isS4(x)) methods::show(x) else print(x)
}

#' Mark an R object with a special class
#'
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ current_input = function(dir = FALSE) {
if (is_abs_path(input)) input else file.path(outwd, input)
}

# import output handlers from evaluate
default_handlers = evaluate:::default_output_handler
# cache output handlers from evaluate; see .onLoad
default_handlers = NULL
# change the value handler in evaluate default handlers
knit_handlers = function(fun, options) {
if (!is.function(fun)) fun = function(x, ...) {
Expand Down
2 changes: 2 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.onLoad = function(lib, pkg) {
register_vignette_engines(pkg)

default_handlers <<- evaluate::new_output_handler()
}

0 comments on commit 389382f

Please sign in to comment.