Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

do not wrap HTML as it was done by default before Pandoc 2.17 #1305

Merged
merged 5 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "xie@yihui.name", 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)
})