knitr 1.46
NEW FEATURES
-
Added a new chunk option
tab.cap
to specify the table caption forkable()
(thanks, @ulyngs, #1679). Previously, the caption could only be specified via thecaption
argument ofkable()
. Now you can set it in the chunk header if you want. Please note that this chunk option only works with a singlekable()
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 argumentsbefore
,options
,envir
, andname
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 thebefore
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
andpngquant
if they are installed and can be found from the systemPATH
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 thepdf
device (thanks, @sebkopf, rstudio/rmarkdown#2526). -
Trailing spaces escaped by
\
should not be trimmed inkable()
(thanks, @mjsmith037, #2308). -
kable()
fails when the value of thecaption
argument is of length > 1 (thanks, @LeeMendelowitz, #2312). -
include_graphics()
may provide an incorrect plot width to LaTeX when the locale setting forLC_NUMERIC
is notC
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 findpdfcrop
(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 thatR 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 duringR 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 asxfun::upload_imgur()
so it is no longer tied to knitr and can be reused by other pakages. Nowknitr::imgur_upload()
is only a wrapper function ofxfun::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
, andprocess_tangle.block/process_tangle.inline -> process_tangle
.