Skip to content

Commit

Permalink
add the <div class="kable-table"> only when the output format is HTML…
Browse files Browse the repository at this point in the history
…, otherwise the div will be converted to a LaTeX environment, leading to the bug https://stackoverflow.com/q/62340425/559676
  • Loading branch information
yihui committed Jun 13, 2020
1 parent 308f1af commit 13a5fbb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rmarkdown
Type: Package
Title: Dynamic Documents for R
Version: 2.2.4
Version: 2.2.5
Authors@R: c(
person("JJ", "Allaire", role = "aut", email = "jj@rstudio.com"),
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rmarkdown 2.3

- Added `publish_site()` function for "one-button" publishing of R Markdown websites.

- When the `df_print` option is `kable` and the output format is not HTML, `<div class="kable-table">` is no longer added to the `kable()` output, because recent versions of Pandoc will convert the `div` to a LaTeX environment when the output format is LaTeX (thanks, Laurens, https://stackoverflow.com/q/62340425/559676).

rmarkdown 2.2
================================================================================

Expand Down
6 changes: 4 additions & 2 deletions R/knit_print.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ knit_print.data.frame <- function(x, ...) {

if (!is.null(context$df_print)) {
if (identical(context$df_print, knitr::kable)) {
res <- one_string(c('<div class="kable-table">', '', knitr::kable(x), '', '</div>'))
knitr::asis_output(res)
res <- c('', knitr::kable(x), '')
if (knitr::is_html_output())
res <- c('<div class="kable-table">', res, '</div>')
knitr::asis_output(one_string(res))
} else {
context$df_print(x)
}
Expand Down

0 comments on commit 13a5fbb

Please sign in to comment.