Skip to content

Commit

Permalink
close #2375: coerce character values to logical for chunk options `me…
Browse files Browse the repository at this point in the history
…ssage` and `warning`
  • Loading branch information
yihui committed Nov 4, 2024
1 parent c81043b commit ec7715c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.48.8
Version: 1.48.9
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Abhraneel", "Sarma", role = "ctb"),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

## MINOR CHANGES

- If a character value is passed to the chunk option `message` or `warning`, it will be coerced by `as.logical()`, e.g., a character string `"NA"` will be coerced to `NA` (thanks, @cderv, #2375).

- Changed the format of the reference card from PDF to HTML so building this package will not require LaTeX. See `vignette('knitr-refcard', package = 'knitr')`.

- Switched the vignette engine from **knitr** to `litedown::vignette` for some package vignettes.
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ dash_names = function(x) {
fix_options = function(options) {
options = as.strict_list(options)

# message/warning take logical or numeric values; if character, convert to logical
for (i in c('message', 'warning')) {
if (is.character(options[[i]])) options[[i]] = as.logical(options[[i]])
}
# if you want to use subfloats, fig.show must be 'hold'
if (length(options$fig.subcap)) options$fig.show = 'hold'
# if the animation hook has been set, fig.show must be 'animate'
Expand Down

0 comments on commit ec7715c

Please sign in to comment.