diff --git a/DESCRIPTION b/DESCRIPTION index 785ed83..9f0dbc7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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")), diff --git a/NEWS.md b/NEWS.md index db3fa0f..6401e21 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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). diff --git a/R/html.R b/R/html.R index 1516f1e..bcb452d 100644 --- a/R/html.R +++ b/R/html.R @@ -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) { diff --git a/R/utils.R b/R/utils.R index 2cff812..466f2d1 100644 --- a/R/utils.R +++ b/R/utils.R @@ -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 + } +}