Skip to content

Commit

Permalink
Collapse messages collected by merge_class()
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- committed Dec 2, 2021
1 parent 5a77add commit 2e37579
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ knit_cnd_format = function(cnd) {

#' @export
knit_cnd_format.message = function(cnd) {
conditionMessage(cnd)
# Character vectors are created by `merge_class()` to support
# https://github.com/yihui/knitr-examples/blob/master/117-messages.Rmd
paste(conditionMessage(cnd), collapse = '')
}

#' @export
Expand Down
9 changes: 9 additions & 0 deletions tests/testit/test-output.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,12 @@ local({
)
})
})

# Character vectors are created by `merge_class()` to support
# https://github.com/yihui/knitr-examples/blob/master/117-messages.Rmd
assert('knit_cnd_format.message() supports character vectors',
identical(
knit_cnd_format(simpleMessage(c("foo", "bar"))),
"foobar"
)
)

0 comments on commit 2e37579

Please sign in to comment.