Skip to content

Commit

Permalink
Add --wrap=preserve by default
Browse files Browse the repository at this point in the history
fixes #115

This handles the changes in Pandoc 2.19+ with default wrapping, as it was needed in bookdown
  • Loading branch information
cderv committed Sep 22, 2022
1 parent ec33df0 commit 668ff40
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: tufte
Title: Tufte's Styles for R Markdown Documents
Version: 0.12.1
Version: 0.12.3
Authors@R: c(
person("Yihui", "Xie", role = "aut", email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Christophe", "Dervieux", role = c("ctb", "cre"), email = "cderv@rstudio.com", comment = c(ORCID = "0000-0003-4474-2498")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CHANGES IN tufte VERSION 0.13

- Fix issue with margin content when using Pandoc 2.19 and later by adding `--wrap preserve` by default (thanks, @TomBen, #115).

# CHANGES IN tufte VERSION 0.12

- Fix footnotes as sidenotes issue with Pandoc 2.15 and later (thanks, @MCMaurer, #108).
Expand Down
3 changes: 3 additions & 0 deletions R/html.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ tufte_html <- function(..., tufte_features = c("fonts", "background", "italics")
format <- html_document2(theme = NULL, ...)
pandoc2 <- pandoc2.0()

# add --wrap=preserve to pandoc args for pandoc 2.0:
format$pandoc$args <- add_wrap_preserve(format$pandoc$args, pandoc2)

# when fig.margin = TRUE, set fig.beforecode = TRUE so plots are moved before
# code blocks, and they can be top-aligned
ohooks <- knitr::opts_hooks$set(fig.margin = function(options) {
Expand Down
11 changes: 11 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,14 @@ template_resources <- function(name, ...) {
gsub_fixed <- function(...) gsub(..., fixed = TRUE)

pandoc2.0 <- function() rmarkdown::pandoc_available("2.0")

# add --wrap=preserve to pandoc args for pandoc 2.0:
# https://github.com/rstudio/bookdown/issues/504
# https://github.com/rstudio/tufte/issues/115
add_wrap_preserve <- function(args, pandoc2 = pandoc2.0) {
if (pandoc2 && !length(grep("--wrap", args))) {
c("--wrap", "preserve", args)
} else {
args
}
}

0 comments on commit 668ff40

Please sign in to comment.