R/hooks.R

Defines functions chunk_hook document_hook text_hook inline_hook plot_hook message_hook warning_hook error_hook output_hook source_hook

source_hook <- function(x, options) {
  insert_text(x, type = "text.source")
  invisible(x)
}

output_hook <- function(x, options) {
  insert_text(x, type = "text.output")
  invisible(x)
}

error_hook <- function(x, options) {
  insert_text(x, type = "text.error")
  invisible(x)
}

warning_hook <- function(x, options) {
  insert_text(x, type = "text.warning")
  invisible(x)
}

message_hook <- function(x, options) {
  insert_text(x, type = "text.message")
  invisible(x)
}

plot_hook <- function(x, options) {
  insert_image(x, width = options$fig.width, height = options$fig.height,
               units = "in", dpi = options$dpi)
  invisible(x)
}

inline_hook <- function(x) {
  invisible(x)
}

text_hook <- function(x) {
  insert_text(stringr::str_trim(x), type = "text")
  invisible(x)
}

document_hook <- function(x) {
  invisible(x)
}

chunk_hook <- function(x, options) {
  invisible(x)
}

Try the knitxl package in your browser

Any scripts or data that you put into this service are public.

knitxl documentation built on April 18, 2023, 5:08 p.m.