From 7f657b95a96ceb9baf12428affa51d6e1f50d1aa Mon Sep 17 00:00:00 2001 From: Elio Campitelli Date: Wed, 24 May 2023 13:12:46 -0300 Subject: [PATCH 1/2] Uses wrap = none for HTML output --- R/bs4_book.R | 2 +- R/ebook.R | 2 +- R/gitbook.R | 2 +- R/html.R | 8 ++++---- R/latex.R | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/bs4_book.R b/R/bs4_book.R index 9f9b13403..aadea41b9 100644 --- a/R/bs4_book.R +++ b/R/bs4_book.R @@ -57,7 +57,7 @@ bs4_book <- function(theme = bs4_book_theme(), self_contained = FALSE, theme = NULL, template = template, - pandoc_args = pandoc_args2(pandoc_args), + pandoc_args = pandoc_args2(pandoc_args, wrap = 'none'), lib_dir = lib_dir, extra_dependencies = c(bs4_book_dependency(theme), extra_dependencies), ... diff --git a/R/ebook.R b/R/ebook.R index f6ddae7ba..eae73e109 100644 --- a/R/ebook.R +++ b/R/ebook.R @@ -88,7 +88,7 @@ process_markdown = function( on.exit(file.remove(intermediate_html), add = TRUE) rmarkdown::pandoc_convert( input_file, 'html', from, intermediate_html, TRUE, - c(pandoc_args2(pandoc_args), '--section-divs', '--mathjax', '--number-sections') + c(pandoc_args2(pandoc_args, wrap = 'none'), '--section-divs', '--mathjax', '--number-sections') ) x = read_utf8(intermediate_html) x = clean_html_tags(x) diff --git a/R/gitbook.R b/R/gitbook.R index 9fb7653bc..1052602c6 100644 --- a/R/gitbook.R +++ b/R/gitbook.R @@ -50,7 +50,7 @@ gitbook = function( toc = TRUE, number_sections = number_sections, fig_caption = fig_caption, self_contained = self_contained, anchor_sections = anchor_sections, lib_dir = lib_dir, theme = NULL, extra_dependencies = extra_dependencies, - template = template, pandoc_args = pandoc_args2(pandoc_args), ... + template = template, pandoc_args = pandoc_args2(pandoc_args, wrap = 'none'), ... ) config$pandoc$lua_filters = append(config$pandoc$lua_filters, lua_filters) split_by = match.arg(split_by) diff --git a/R/html.R b/R/html.R index 988d6c5db..72adb1132 100644 --- a/R/html.R +++ b/R/html.R @@ -59,7 +59,7 @@ html_chapters = function( config = get_base_format(base_format, list( toc = toc, number_sections = number_sections, fig_caption = fig_caption, self_contained = FALSE, lib_dir = lib_dir, - template = template, pandoc_args = pandoc_args2(pandoc_args), ... + template = template, pandoc_args = pandoc_args2(pandoc_args, wrap = 'none'), ... )) split_by = match.arg(split_by) post = config$post_processor # in case a post processor have been defined @@ -77,8 +77,8 @@ html_chapters = function( # add --wrap=preserve to pandoc args for pandoc 2.0: # https://github.com/rstudio/bookdown/issues/504 -pandoc_args2 = function(args) { - if (pandoc2.0() && !length(grep('--wrap', args))) c('--wrap', 'preserve', args) else args +pandoc_args2 = function(args, wrap = 'preserve') { + if (pandoc2.0() && !length(grep('--wrap', args))) c('--wrap', wrap, args) else args } #' @rdname html_chapters @@ -135,7 +135,7 @@ html_document2 = function( pandoc_args = NULL, base_format = rmarkdown::html_document ) { config = get_base_format(base_format, list( - ..., number_sections = number_sections, pandoc_args = pandoc_args2(pandoc_args) + ..., number_sections = number_sections, pandoc_args = pandoc_args2(pandoc_args, wrap = 'none') )) post = config$post_processor # in case a post processor have been defined config$post_processor = function(metadata, input, output, clean, verbose) { diff --git a/R/latex.R b/R/latex.R index c8835ccd4..1b5cbde3a 100644 --- a/R/latex.R +++ b/R/latex.R @@ -38,7 +38,7 @@ pdf_book = function( ) { config = get_base_format(base_format, list( toc = toc, number_sections = number_sections, fig_caption = fig_caption, - pandoc_args = pandoc_args2(pandoc_args), ... + pandoc_args = pandoc_args2(pandoc_args, wrap = "preserve"), ... )) config$pandoc$ext = '.tex' post = config$post_processor # in case a post processor have been defined From 882be2f9bf01257634098cba5be2355990c9fb73 Mon Sep 17 00:00:00 2001 From: Elio Campitelli Date: Thu, 25 May 2023 14:13:20 -0300 Subject: [PATCH 2/2] Uses wrap=preserve for gitbook --- R/gitbook.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/gitbook.R b/R/gitbook.R index 1052602c6..6359c6c97 100644 --- a/R/gitbook.R +++ b/R/gitbook.R @@ -50,7 +50,7 @@ gitbook = function( toc = TRUE, number_sections = number_sections, fig_caption = fig_caption, self_contained = self_contained, anchor_sections = anchor_sections, lib_dir = lib_dir, theme = NULL, extra_dependencies = extra_dependencies, - template = template, pandoc_args = pandoc_args2(pandoc_args, wrap = 'none'), ... + template = template, pandoc_args = pandoc_args2(pandoc_args, wrap = 'preserve'), ... ) config$pandoc$lua_filters = append(config$pandoc$lua_filters, lua_filters) split_by = match.arg(split_by)