Skip to content

Commit

Permalink
Fix the error when kable()'s caption value is of length > 1 (#2312)
Browse files Browse the repository at this point in the history
Co-authored-by: Yihui Xie <[email protected]>
  • Loading branch information
LeeMendelowitz and yihui authored Dec 11, 2023
1 parent b037a31 commit 1822137
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

- 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).

## 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.
Expand Down
2 changes: 1 addition & 1 deletion R/table.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ kable_caption = function(label, caption, format) {
# create a label for bookdown if applicable
if (is.null(label)) label = opts_current$get('label')
if (is.null(label)) label = NA
if (!is.null(caption) && !is.na(caption) && !is.na(label)) caption = paste0(
if (!is.null(caption) && !anyNA(caption) && !anyNA(label)) caption = paste0(
create_label(
opts_knit$get('label.prefix')[['table']],
label, latex = (format == 'latex')
Expand Down

0 comments on commit 1822137

Please sign in to comment.