Skip to content

knitr 1.46

Compare
Choose a tag to compare
@yihui yihui released this 06 Apr 23:07
· 54 commits to master since this release

NEW FEATURES

  • Added a new chunk option tab.cap to specify the table caption for kable() (thanks, @ulyngs, #1679). Previously, the caption could only be specified via the caption argument of kable(). Now you can set it in the chunk header if you want. Please note that this chunk option only works with a single kable() in each code chunk, and its value must be of length 1.

  • spin() now recognizes # %% as a valid code chunk delimiter (thanks, @kylebutts, #2307).

  • spin() also recognizes #| comments as code chunks now (thanks, @kylebutts, #2320).

  • Chunk hooks can have the ... argument now. Previously, only arguments before, options, envir, and name are accepted. If a chunk hook function has the ... argument, all the aforementioned four arguments are passed to the hook. This means the hook function no longer has to have the four arguments explicitly in its signature, e.g., function(before, ...) is also valid if only the before argument is used inside the hook. See https://yihui.org/knitr/hooks/#chunk-hooks for more information.

  • For package vignettes, PNG plots will be optimized by optipng and pngquant if they are installed and can be found from the system PATH variable. This can help reduce the package size if vignettes contain PNG plots (thanks, @nanxstats, https://nanx.me/blog/post/rpkgs-pngquant-ragg/).

BUG FIXES

  • spin() stopped working with input that cannot be parsed as R code due to #1605. Now it works again (thanks, @Hemken, #1773).

  • write_bib() generated empty entries for packages without URLs (thanks, @bastistician, #2304).

  • The family argument was not passed to the pdf device (thanks, @sebkopf, rstudio/rmarkdown#2526).

  • Trailing spaces escaped by \ should not be trimmed in kable() (thanks, @mjsmith037, #2308).

  • kable() fails when the value of the caption argument is of length > 1 (thanks, @LeeMendelowitz, #2312).

  • include_graphics() may provide an incorrect plot width to LaTeX when the locale setting for LC_NUMERIC is not C because the decimal separator may not be a dot (thanks, @tdhock, rstudio/rmarkdown#2525).

  • When TinyTeX and the LaTeX package pdfcrop are installed, knitr::pdf_crop() is unable to find pdfcrop (thanks, @dmkaplan2000, rstudio/tinytex#435).

MAJOR CHANGES

  • Unbalanced chunk delimiters (fences) in R Markdown documents are no longer allowed, as announced two years ago at https://yihui.org/en/2021/10/unbalanced-delimiters/ (#2306). This means the opening delimiter must strictly match the closing delimiter, e.g., if a code chunk starts with four backticks, it must also end with four; or if a chunk header is indented by two spaces, the closing fence must be indented by exactly two spaces. For authors who cannot update their R Markdown documents for any reason at the moment, setting options(knitr.unbalanced.chunk = TRUE) (e.g., in .Rprofile) can temporarily prevent knitr from throwing an error, but it is strongly recommended that you fix the problems as soon as possible, because this workaround will be removed in future.

  • Package vignettes are tangled by default during R CMD check, per request from CRAN maintainers (d0d1b47). The consequence is that R CMD check will check R scripts tangled from vignettes by default, unless you set the environment variable _R_CHECK_VIGNETTES_SKIP_RUN_MAYBE_=true. Previously, knitr would skip tangling vignettes during R CMD check, because R scripts tangled from vignettes are not guaranteed to valid. With the skip undone, R CMD check may fail in places other than CRAN (because CRAN has set the environment variable).

MINOR CHANGES

  • Fixed broken vignettes, improved CSS for HTML vignettes, and reduced the file sizes.

  • SQL code chunks that run ALTER statements are only executed and not tried to fecth a result (thanks, @maxschmi, #2330).

  • The function imgur_upload() has been moved to (and enhanced in) the xfun package as xfun::upload_imgur() so it is no longer tied to knitr and can be reused by other pakages. Now knitr::imgur_upload() is only a wrapper function of xfun::upload_imgur(). You are recommended to use the latter (#2325).

  • spin() dropped support for #- as the chunk delimiter token. Please use #+ or # %% or #| instead.

  • Faster processing of cache dependencies in dep_auto() (thanks, @knokknok, #2318).

  • Removed some S3 methods that are used internally and changed them to normal functions: print.block -> print_block, print.inline -> print_inline, process_group.block/process_group.inline -> process_group, and process_tangle.block/process_tangle.inline -> process_tangle.