Skip to content

Commit

Permalink
Fix automatic wrapping by Pandoc 2.17 in our pre processing (rstudio#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv authored Jan 24, 2022
1 parent 236e07b commit 6931d14
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: bookdown
Type: Package
Title: Authoring Books and Technical Documents with R Markdown
Version: 0.24.5
Version: 0.24.6
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("JJ", "Allaire", role = "ctb"),
Expand Down
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

## BUG FIXES

- Fix an issue with Pandoc 2.15 and footnote relocation in each chapter (#1275).

- Fix an issue with Pandoc 2.17 and internationalization of Proof-like environment (#1302).

- Fix an issue with Pandoc 2.17 and cross referencing sections in non HTML format (thanks, @N0rbert, #7862).

- Fix an issue with Pandoc 2.15 and footnote relocation in each chapter (#1275).

- Fix an issue with `html_book()` and `toc.css` not working correctly with recent pandoc (thanks, @florisvdh, #1268).

# CHANGES IN bookdown VERSION 0.24
Expand Down
2 changes: 1 addition & 1 deletion R/ebook.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ process_markdown = function(
on.exit(file.remove(intermediate_html), add = TRUE)
rmarkdown::pandoc_convert(
input_file, 'html', from, intermediate_html, TRUE,
c(pandoc_args, '--section-divs', '--mathjax', '--number-sections')
c(pandoc_args2(pandoc_args), '--section-divs', '--mathjax', '--number-sections')
)
x = read_utf8(intermediate_html)
x = clean_html_tags(x)
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ skip_if_pandoc <- function(ver = NULL) {
}
}

local_rmd_file <- function(..., .env = parent.frame()) {
path <- withr::local_tempfile(.local_envir = .env, fileext = ".Rmd")
xfun::write_utf8(c(...), path)
path
}

local_render <- function(input, ..., .env = parent.frame()) {
skip_if_not_pandoc()
output_file <- withr::local_tempfile(.local_envir = .env)
rmarkdown::render(input, output_file = output_file, quiet = TRUE, ...)
}

.render_and_read <- function(input, ...) {
skip_if_not_pandoc()
res <- local_render(input, ...)
xfun::read_utf8(res)
}

local_book <- function(name = "book",
title = "Awesome Cookbook",
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-word.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test_that("process_markdown() correctly resolves reference", {
skip_if_not_pandoc()
# testing using markdown_document2() for snapshotting easier
rmd <- local_rmd_file(
"# Theory {#theory}", "", "see \\@ref(label1)", "",
"## Some other header {#label1}", "", "Content"
)
content <- .render_and_read(rmd, output_format = markdown_document2())
expect_match(content, 'see <a href="#label1">1.1</a>', fixed = TRUE, all = FALSE)
})

0 comments on commit 6931d14

Please sign in to comment.