Skip to content

Commit

Permalink
Merge remote-tracking branch 'rstudio_origin/main'
Browse files Browse the repository at this point in the history
* rstudio_origin/main:
  Add support for devtools loaded package in `draft()` (rstudio#2224)
  Fix typo in comment
  import bslib (rstudio#2154)
  CRAN release v2.11
  https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html -> https://pandoc.org/MANUAL.html#citations
  Add a specific dirname for sass caching
  roxygenize and bump version
  export convert_ipynb() per suggestion of @acircleda
  use sass::output_template() instead of storing a copy in rmarkdown
  fix yihui/xaringan#331: respect relative paths in parent directories in the `css` argument of `html_document()`
  Bump version
  Prerender shiny rmd in separate environment (rstudio#2203)
  Mark result of citeproc conversion as UTF-8 (rstudio#2202)
  • Loading branch information
jonathan-g committed Sep 27, 2021
2 parents 8282527 + 71ae829 commit 81d52ec
Show file tree
Hide file tree
Showing 28 changed files with 127 additions and 62 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rmarkdown
Type: Package
Title: Dynamic Documents for R
Version: 2.10.2
Version: 2.11.2
Authors@R: c(
person("JJ", "Allaire", role = "aut", email = "[email protected]"),
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
Expand Down Expand Up @@ -89,6 +89,7 @@ Imports:
tinytex (>= 0.31),
xfun (>= 0.21),
jquerylib,
bslib (>= 0.2.5.1),
methods,
stringr (>= 1.2.0)
Suggests:
Expand All @@ -102,12 +103,11 @@ Suggests:
fs,
rsconnect,
withr (>= 2.4.2),
bslib (>= 0.2.5.1),
sass (>= 0.4.0)
SystemRequirements: pandoc (>= 1.14) - http://pandoc.org
URL: https://github.com/rstudio/rmarkdown, https://pkgs.rstudio.com/rmarkdown/
BugReports: https://github.com/rstudio/rmarkdown/issues
License: GPL-3
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
Encoding: UTF-8
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export(all_output_formats)
export(beamer_presentation)
export(clean_site)
export(context_document)
export(convert_ipynb)
export(default_output_format)
export(default_site_generator)
export(draft)
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
rmarkdown 2.12
================================================================================

- `draft()` now works with `devtools::load_all()` and **testthat** when used in other packages.

rmarkdown 2.11
================================================================================

- Relative paths in parent directories in the `css` argument of `html_document()` were incorrectly normalized to absolute paths by #2095 in v2.8. Now relative paths in parent directories will no longer be converted to absolute paths (thanks, @daijiang, yihui/xaringan#331).

- It is possible to specify the version of jQuery via a global option now, e.g., `options(rmarkdown.jquery.version = 2)` (note that the default major version is `3`). This is mainly for advanced users and developers to test different versions of jQuery.

- `pandoc_citeproc_convert()` now handles correctly bib file containing specific UTF-8 characters on non default UTF-8 systems like Windows (thanks, @mitchelloharawild, #2195).

- Shiny prerendered documents are now pre-rendered in a child environment to avoid allowing the results of static code chunks to exist in the Shiny app environment (@gadenbuie, #2203).

- The previously unexported function `convert_ipynb()` is exported now (thanks, @acircleda).


rmarkdown 2.10
================================================================================
Expand Down
2 changes: 1 addition & 1 deletion R/beamer_presentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#'
#' R Markdown documents also support citations. You can find more information on
#' the markdown syntax for citations in the
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
#' and Citations} article in the online documentation.
#' @inheritParams pdf_document
#' @inheritParams html_document
Expand Down
2 changes: 1 addition & 1 deletion R/context_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#'
#' R Markdown documents also support citations. You can find more information on
#' the markdown syntax for citations in the
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
#' and Citations} article in the online documentation.
#' @inheritParams pdf_document
#' @param context_path Path of the ConTeXt executable. If not provided, ConTeXt has
Expand Down
2 changes: 1 addition & 1 deletion R/draft.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ draft <- function(file,

# resolve package file
if (!is.null(package)) {
template_path = system.file("rmarkdown", "templates", template,
template_path = pkg_file("rmarkdown", "templates", template,
package = package)
if (!nzchar(template_path)) {
stop("The template '", template, "' was not found in the ",
Expand Down
2 changes: 1 addition & 1 deletion R/html_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'
#' R Markdown documents also support citations. You can find more information on
#' the markdown syntax for citations in the
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
#' and Citations} article in the online documentation.
#'
#'@inheritParams output_format
Expand Down
33 changes: 5 additions & 28 deletions R/html_document_base.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ html_document_base <- function(theme = NULL,
bootstrap_compatible = FALSE,
...) {

# default for dependency_resovler
# default for dependency_resolver
if (is.null(dependency_resolver))
dependency_resolver <- html_dependency_resolver

Expand Down Expand Up @@ -99,15 +99,15 @@ html_document_base <- function(theme = NULL,
f <- sass::sass(
sass::sass_file(f),
# write output file to `lib_dir/sass-{sass:::sass_hash()}{[basename(f)}`
output = sass_output_template(
output = sass::output_template(
basename = xfun::sans_ext(basename(f)),
tmpdir = lib_dir
dirname = "sass",
path = lib_dir
),
options = sass::sass_options(output_style = "compressed")
)
f <- normalized_relative_to(output_dir, f)
}
# do not normalize web path
if (!xfun::is_web_path(f)) f <- normalized_relative_to(output_dir, f)
args <- c(args, "--css", pandoc_path_arg(f, backslash = FALSE))
}

Expand Down Expand Up @@ -245,26 +245,3 @@ extract_preserve_chunks <- function(input_file, extract = extractPreserveChunks)
if (!identical(preserve$value, input_str)) write_utf8(preserve$value, input_file)
preserve$chunks
}


# inspired by sass::output_template but writes to a custom temp dir instead of only tempdir()
# TODO: use the one from sass package when sass 0.3.2 in on CRAN (rstudio/sass#77)
sass_output_template <- function(basename = "rmarkdown", dirname = "sass",
fileext = NULL, tmpdir = tempdir()) {
function(options = list(), suffix = NULL) {
fileext <- fileext %||% if (isTRUE(options$output_style %in%
c(2, 3)))
".min.css"
else ".css"
out_dir <- if (is.null(suffix)) {
tempfile(tmpdir = tmpdir, pattern = dirname)
}
else {
file.path(tmpdir, paste0(dirname, suffix))
}
if (!dir.exists(out_dir)) {
dir.create(out_dir, recursive = TRUE)
}
file.path(out_dir, paste0(basename, fileext))
}
}
2 changes: 1 addition & 1 deletion R/jupyter.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' @param input Path to the input \file{.ipynb} file.
#' @param output The output file path.
#' @return The output file path (invisibly).
#' @keywords internal
#' @export
#' @examples
#' # this is not a real ipynb file, but illustrates what convert_ipynb() does
#' nb_data <- list(
Expand Down
2 changes: 1 addition & 1 deletion R/odt_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' R Markdown documents also support citations. You can find more information on
#' the markdown syntax for citations in the
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
#' and Citations} article in the online documentation.
#' @inheritParams pdf_document
#' @inheritParams html_document
Expand Down
2 changes: 2 additions & 0 deletions R/pandoc.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ pandoc_citeproc_convert <- function(file, type = c("list", "json", "yaml")) {
stop("Error ", status, " occurred building shared library.")
}

Encoding(result) <- "UTF-8"

# convert the output if requested
if (type == "list") {
jsonlite::fromJSON(result, simplifyVector = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion R/pdf_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#'
#' R Markdown documents also support citations. You can find more information on
#' the markdown syntax for citations in the
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
#' and Citations} article in the online documentation.
#'
#' Many aspects of the LaTeX template used to create PDF documents can be
Expand Down
2 changes: 1 addition & 1 deletion R/rtf_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' R Markdown documents also support citations. You can find more information on
#' the markdown syntax for citations in the
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
#' and Citations} article in the online documentation.
#' @inheritParams pdf_document
#' @inheritParams html_document
Expand Down
5 changes: 4 additions & 1 deletion R/shiny_prerendered.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ shiny_prerendered_html <- function(input_rmd, render_args) {

# prerender if necessary
if (prerender) {
args <- merge_lists(list(input = input_rmd), render_args)
# force prerender to execute in separate environment to ensure that
# running w/ prerender step is equivalent to running the prerendered app
args$envir <- new.env(parent = args$envir %||% globalenv())

# execute the render
args <- merge_lists(list(input = input_rmd), render_args)
rendered_html <- do.call(render, args)
}

Expand Down
19 changes: 11 additions & 8 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ pandoc_output_ext <- function(ext, to, input) {
# From pkgdown:
# https://github.com/r-lib/pkgdown/blob/04d3a76892320ac4bd918b39604c157e9f83507a/R/utils-fs.R#L85
pkg_file <- function(..., package = "rmarkdown", mustWork = FALSE) {
if (is.null(devtools_meta(package))) {
system.file(..., package = package, mustWork = mustWork)
} else {
if (devtools_loaded(package)) {
# used only if package has been loaded with devtools or pkgload
file.path(getNamespaceInfo(package, "path"), "inst", ...)
file.path(find.package(package), "inst", ...)
} else {
system.file(..., package = package, mustWork = mustWork)
}
}

Expand Down Expand Up @@ -566,10 +566,13 @@ stop2 = function(...) stop(..., call. = FALSE)

# devtools metadata -------------------------------------------------------

# from pkgdown
# from pkgdown & downlit
# https://github.com/r-lib/pkgdown/blob/77f909b0138a1d7191ad9bb3cf95e78d8e8d93b9/R/utils.r#L52

devtools_meta <- function(package) {
ns <- .getNamespace(package)
ns[[".__DEVTOOLS__"]]
devtools_loaded <- function(x) {
if (!x %in% loadedNamespaces()) {
return(FALSE)
}
ns <- .getNamespace(x)
!is.null(ns$.__DEVTOOLS__)
}
2 changes: 1 addition & 1 deletion R/word_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#'
#' R Markdown documents also support citations. You can find more information on
#' the markdown syntax for citations in the
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
#' and Citations} article in the online documentation.
#' @inheritParams pdf_document
#' @inheritParams html_document
Expand Down
2 changes: 1 addition & 1 deletion man/beamer_presentation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/context_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/convert_ipynb.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/html_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/md_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/odt_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/pdf_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/rtf_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/word_document.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions tests/testthat/_snaps/pandoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Converting bib file is working

list(list(author = list(list(family = "Conceição", given = "Sérgio")),
"container-title" = "Portuguese History", id = "conc2021",
issue = "1", issued = list("date-parts" = list(list(2021L))),
title = "História da habitação", type = "article-journal"))

---

[1] "["
[2] " {"
[3] " \"author\": ["
[4] " {"
[5] " \"family\": \"Conceição\","
[6] " \"given\": \"Sérgio\""
[7] " }"
[8] " ],"
[9] " \"container-title\": \"Portuguese History\","
[10] " \"id\": \"conc2021\","
[11] " \"issue\": \"1\","
[12] " \"issued\": {"
[13] " \"date-parts\": ["
[14] " ["
[15] " 2021"
[16] " ]"
[17] " ]"
[18] " },"
[19] " \"title\": \"História da habitação\","
[20] " \"type\": \"article-journal\""
[21] " }"
[22] "]"

---

[1] "---"
[2] "nocite: \"[@*]\""
[3] "references:"
[4] "- author:"
[5] " - family: Conceição"
[6] " given: Sérgio"
[7] " container-title: Portuguese History"
[8] " id: conc2021"
[9] " issue: 1"
[10] " issued: 2021"
[11] " title: História da habitação"
[12] " type: article-journal"
[13] "---"
[14] ""

7 changes: 7 additions & 0 deletions tests/testthat/resources/UTF8.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@article{conc2021,
title={História da Habitação},
author={Conceição, Sérgio},
journal={Portuguese History},
number={1},
year={2021}
}
Loading

0 comments on commit 81d52ec

Please sign in to comment.