Skip to content

Commit

Permalink
Merge latest changes from the rstudio main branch.
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'rstudio_origin/main' into jg-tree-fix

# By Christophe Dervieux (2) and Yihui Xie (1)
# Via Christophe Dervieux
* rstudio_origin/main:
  Add class to book cover to size using CSS
  fix the syntax highlighting of |> in LaTeX/PDF output: rstudio/bookdown#1157 (rstudio#2228)
  Add an option to opt-out the header-attrs HTML dependency in `html_document_base()` (rstudio#2227)

# Conflicts:
#	NEWS.md
  • Loading branch information
jonathan-g committed Oct 30, 2021
2 parents dc85e0d + ebf0d09 commit 337a6e2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 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.11.2
Version: 2.11.3
Authors@R: c(
person("JJ", "Allaire", role = "aut", email = "[email protected]"),
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", 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 @@ -8,6 +8,8 @@ rmarkdown 2.12
where there is a shared master library with css, javascript, etc. and separate
child directories with RMarkdown files. #146 and #1859.

- Added a global option `rmarkdown.html_dependency.header_attr` (`TRUE` by default). It can be set to `FALSE` to opt-out the HTML dependency `html_dependency_header_attrs()` in documents based on `html_document_base()` (thanks, @salim-b rstudio/bookdown#865, @maelle r-lib/downlit#1538).

- `draft()` now works with `devtools::load_all()` and **testthat** when used in other packages.

rmarkdown 2.11
Expand Down
16 changes: 9 additions & 7 deletions R/html_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,14 @@ html_dependency_rsiframe <- function() {
# Pandoc 2.9 adds attributes on both headers and their parent divs. We remove
# the ones on headers since they are unnecessary (#1723).
html_dependency_header_attrs <- function() {
if (pandoc_available('2.9')) list(
htmlDependency(
"header-attrs",
version = packageVersion("rmarkdown"),
src = pkg_file("rmd/h/pandoc"),
script = "header-attrs.js"
if (getOption('rmarkdown.html_dependency.header_attr', TRUE) && pandoc_available('2.9')) {
list(
htmlDependency(
"header-attrs",
version = packageVersion("rmarkdown"),
src = pkg_file("rmd/h/pandoc"),
script = "header-attrs.js"
)
)
)
}
}
12 changes: 12 additions & 0 deletions R/pdf_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ pdf_document <- function(toc = FALSE,
output_dir)
}

post_processor <- function(metadata, input_file, output_file, clean, verbose) {
# TODO: remove this temporary fix after the syntax highlighting problem is
# fixed in Pandoc https://github.com/rstudio/bookdown/issues/1157
x <- read_utf8(output_file)
s <- '\\SpecialCharTok{|}\\ErrorTok{\\textgreater{}}'
if (length(grep(s, x, fixed = TRUE)) == 0) return(output_file)
x <- gsub(s, '\\SpecialCharTok{|\\textgreater{}}', x, fixed = TRUE)
write_utf8(x, output_file)
output_file
}

intermediates_generator <- function(...) {
general_intermediates_generator(saved_files_dir, ...)
}
Expand All @@ -207,6 +218,7 @@ pdf_document <- function(toc = FALSE,
keep_md = keep_md,
df_print = df_print,
pre_processor = pre_processor,
post_processor = post_processor,
intermediates_generator = intermediates_generator
)
}
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ R Markdown documents can be rendered to many output formats including HTML docum

## Books


<a href="https://bookdown.org/yihui/rmarkdown/"><img src="https://bookdown.org/yihui/rmarkdown/images/cover.png" alt="R Markdown: The Definitive Guide" height="400"></a>
<a href="https://bookdown.org/yihui/rmarkdown-cookbook/"><img src="https://bookdown.org/yihui/rmarkdown-cookbook/images/cover.png" alt="R Markdown Cookbook" height="400"></a>
<a href="https://bookdown.org/yihui/rmarkdown/"><img class="book" src="https://bookdown.org/yihui/rmarkdown/images/cover.png" alt="R Markdown: The Definitive Guide" height="400"></a>
<a href="https://bookdown.org/yihui/rmarkdown-cookbook/"><img class="book" src="https://bookdown.org/yihui/rmarkdown-cookbook/images/cover.png" alt="R Markdown Cookbook" height="400"></a>

See more about them in [Get Started](https://pkgs.rstudio.com/rmarkdown/articles/rmarkdown.html).

Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-html_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,8 @@ test_that("html_dependencies_fonts loads the correct fonts dep", {
expect_identical(html_dependencies_fonts(FALSE, TRUE), list(io))
expect_identical(html_dependencies_fonts(TRUE, TRUE), list(fa, io))
})

test_that("header-attr can be opt-out", {
withr::local_options(list(rmarkdown.html_dependency.header_attr = FALSE))
expect_null(html_dependency_header_attrs())
})

0 comments on commit 337a6e2

Please sign in to comment.