res1 <- set_knit_hooks(h.1, .test = TRUE)

Set hooks:  output 
<STYLE type='text/css' scoped>
PRE.fansi SPAN {padding-top: .25em; padding-bottom: .25em};
</STYLE>

<PRE class="fansi fansi-output"><CODE>hello<span style='color: #BB0000;'> world</span></CODE></PRE>

[1] "<PRE class=\"fansi fansi-output\"><CODE>hello<span style='color: #BB0000;'> world</span></CODE></PRE>"

res1a <- set_knit_hooks(h.1, split.nl = TRUE, .test = TRUE)

<PRE class="fansi fansi-output"><CODE>hello<span style='color: #BB0000;'> wo</span>
<span style='color: #BB0000;'>rld</span></CODE></PRE>

[1] "<PRE class=\"fansi fansi-output\"><CODE>hello<span style='color: #BB0000;'> wo</span>\n<span style='color: #BB0000;'>rld</span></CODE></PRE>"

p.f.3 <- function(x, class) sprintf("new proc fun, '%s'", class)

p.f.4 <- function(x, class) stop("new proc fun")

Argument `split.n` must be TRUE or FALSE

Error in set_knit_hooks(h.1, split.nl = "banana") : 
  Argument `split.n` must be TRUE or FALSE

Argument `proc.fun` must be a function with formals named `x` and `class`.

Error in set_knit_hooks(h.1, proc.fun = p.f.2) : 
  Argument `proc.fun` must be a function with formals named `x` and `class`.

Argument `which` must be character containing values in c("output", "warning", "error", "message")

Error in set_knit_hooks(h.1, which = "hello") : 
  Argument `which` must be character containing values in c("output", "warning", "error", "message")

Error in set_knit_hooks(h.1, which = NULL) : 
  Argument `which` must be character containing values in c("output", "warning", "error", "message")

res2 <- set_knit_hooks(h.1, which = c("output", "message"), class = c("f-output", 
    "f-message"), proc.fun = p.f.3, .test = TRUE)

Set hooks:  output message 
<STYLE type='text/css' scoped>
PRE.fansi SPAN {padding-top: .25em; padding-bottom: .25em};
</STYLE>

res3 <- set_knit_hooks(h.1, which = c("message", "warning"), 
    proc.fun = p.f.4, .test = TRUE)

Set hooks:  message warning 
<STYLE type='text/css' scoped>
PRE.fansi SPAN {padding-top: .25em; padding-bottom: .25em};
</STYLE>