Skip to content

Commit 81d52ec

Browse files
committed
Merge remote-tracking branch 'rstudio_origin/main'
* 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)
2 parents 8282527 + 71ae829 commit 81d52ec

28 files changed

+127
-62
lines changed

DESCRIPTION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: rmarkdown
22
Type: Package
33
Title: Dynamic Documents for R
4-
Version: 2.10.2
4+
Version: 2.11.2
55
Authors@R: c(
66
person("JJ", "Allaire", role = "aut", email = "[email protected]"),
77
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
@@ -89,6 +89,7 @@ Imports:
8989
tinytex (>= 0.31),
9090
xfun (>= 0.21),
9191
jquerylib,
92+
bslib (>= 0.2.5.1),
9293
methods,
9394
stringr (>= 1.2.0)
9495
Suggests:
@@ -102,12 +103,11 @@ Suggests:
102103
fs,
103104
rsconnect,
104105
withr (>= 2.4.2),
105-
bslib (>= 0.2.5.1),
106106
sass (>= 0.4.0)
107107
SystemRequirements: pandoc (>= 1.14) - http://pandoc.org
108108
URL: https://github.com/rstudio/rmarkdown, https://pkgs.rstudio.com/rmarkdown/
109109
BugReports: https://github.com/rstudio/rmarkdown/issues
110110
License: GPL-3
111-
RoxygenNote: 7.1.1
111+
RoxygenNote: 7.1.2
112112
Encoding: UTF-8
113113
VignetteBuilder: knitr

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export(all_output_formats)
1111
export(beamer_presentation)
1212
export(clean_site)
1313
export(context_document)
14+
export(convert_ipynb)
1415
export(default_output_format)
1516
export(default_site_generator)
1617
export(draft)

NEWS.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
rmarkdown 2.12
2+
================================================================================
3+
4+
- `draft()` now works with `devtools::load_all()` and **testthat** when used in other packages.
5+
16
rmarkdown 2.11
27
================================================================================
38

9+
- 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).
10+
411
- 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.
512

13+
- `pandoc_citeproc_convert()` now handles correctly bib file containing specific UTF-8 characters on non default UTF-8 systems like Windows (thanks, @mitchelloharawild, #2195).
14+
15+
- 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).
16+
17+
- The previously unexported function `convert_ipynb()` is exported now (thanks, @acircleda).
18+
619

720
rmarkdown 2.10
821
================================================================================

R/beamer_presentation.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#'
1515
#' R Markdown documents also support citations. You can find more information on
1616
#' the markdown syntax for citations in the
17-
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
17+
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
1818
#' and Citations} article in the online documentation.
1919
#' @inheritParams pdf_document
2020
#' @inheritParams html_document

R/context_document.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#'
1515
#' R Markdown documents also support citations. You can find more information on
1616
#' the markdown syntax for citations in the
17-
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
17+
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
1818
#' and Citations} article in the online documentation.
1919
#' @inheritParams pdf_document
2020
#' @param context_path Path of the ConTeXt executable. If not provided, ConTeXt has

R/draft.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ draft <- function(file,
6363

6464
# resolve package file
6565
if (!is.null(package)) {
66-
template_path = system.file("rmarkdown", "templates", template,
66+
template_path = pkg_file("rmarkdown", "templates", template,
6767
package = package)
6868
if (!nzchar(template_path)) {
6969
stop("The template '", template, "' was not found in the ",

R/html_document.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#'
1313
#' R Markdown documents also support citations. You can find more information on
1414
#' the markdown syntax for citations in the
15-
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
15+
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
1616
#' and Citations} article in the online documentation.
1717
#'
1818
#'@inheritParams output_format

R/html_document_base.R

+5-28
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ html_document_base <- function(theme = NULL,
2929
bootstrap_compatible = FALSE,
3030
...) {
3131

32-
# default for dependency_resovler
32+
# default for dependency_resolver
3333
if (is.null(dependency_resolver))
3434
dependency_resolver <- html_dependency_resolver
3535

@@ -99,15 +99,15 @@ html_document_base <- function(theme = NULL,
9999
f <- sass::sass(
100100
sass::sass_file(f),
101101
# write output file to `lib_dir/sass-{sass:::sass_hash()}{[basename(f)}`
102-
output = sass_output_template(
102+
output = sass::output_template(
103103
basename = xfun::sans_ext(basename(f)),
104-
tmpdir = lib_dir
104+
dirname = "sass",
105+
path = lib_dir
105106
),
106107
options = sass::sass_options(output_style = "compressed")
107108
)
109+
f <- normalized_relative_to(output_dir, f)
108110
}
109-
# do not normalize web path
110-
if (!xfun::is_web_path(f)) f <- normalized_relative_to(output_dir, f)
111111
args <- c(args, "--css", pandoc_path_arg(f, backslash = FALSE))
112112
}
113113

@@ -245,26 +245,3 @@ extract_preserve_chunks <- function(input_file, extract = extractPreserveChunks)
245245
if (!identical(preserve$value, input_str)) write_utf8(preserve$value, input_file)
246246
preserve$chunks
247247
}
248-
249-
250-
# inspired by sass::output_template but writes to a custom temp dir instead of only tempdir()
251-
# TODO: use the one from sass package when sass 0.3.2 in on CRAN (rstudio/sass#77)
252-
sass_output_template <- function(basename = "rmarkdown", dirname = "sass",
253-
fileext = NULL, tmpdir = tempdir()) {
254-
function(options = list(), suffix = NULL) {
255-
fileext <- fileext %||% if (isTRUE(options$output_style %in%
256-
c(2, 3)))
257-
".min.css"
258-
else ".css"
259-
out_dir <- if (is.null(suffix)) {
260-
tempfile(tmpdir = tmpdir, pattern = dirname)
261-
}
262-
else {
263-
file.path(tmpdir, paste0(dirname, suffix))
264-
}
265-
if (!dir.exists(out_dir)) {
266-
dir.create(out_dir, recursive = TRUE)
267-
}
268-
file.path(out_dir, paste0(basename, fileext))
269-
}
270-
}

R/jupyter.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#' @param input Path to the input \file{.ipynb} file.
2020
#' @param output The output file path.
2121
#' @return The output file path (invisibly).
22-
#' @keywords internal
22+
#' @export
2323
#' @examples
2424
#' # this is not a real ipynb file, but illustrates what convert_ipynb() does
2525
#' nb_data <- list(

R/odt_document.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#'
1212
#' R Markdown documents also support citations. You can find more information on
1313
#' the markdown syntax for citations in the
14-
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
14+
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
1515
#' and Citations} article in the online documentation.
1616
#' @inheritParams pdf_document
1717
#' @inheritParams html_document

R/pandoc.R

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ pandoc_citeproc_convert <- function(file, type = c("list", "json", "yaml")) {
157157
stop("Error ", status, " occurred building shared library.")
158158
}
159159

160+
Encoding(result) <- "UTF-8"
161+
160162
# convert the output if requested
161163
if (type == "list") {
162164
jsonlite::fromJSON(result, simplifyVector = FALSE)

R/pdf_document.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#'
1515
#' R Markdown documents also support citations. You can find more information on
1616
#' the markdown syntax for citations in the
17-
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
17+
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
1818
#' and Citations} article in the online documentation.
1919
#'
2020
#' Many aspects of the LaTeX template used to create PDF documents can be

R/rtf_document.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#'
1212
#' R Markdown documents also support citations. You can find more information on
1313
#' the markdown syntax for citations in the
14-
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
14+
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
1515
#' and Citations} article in the online documentation.
1616
#' @inheritParams pdf_document
1717
#' @inheritParams html_document

R/shiny_prerendered.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ shiny_prerendered_html <- function(input_rmd, render_args) {
117117

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

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

R/util.R

+11-8
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ pandoc_output_ext <- function(ext, to, input) {
4747
# From pkgdown:
4848
# https://github.com/r-lib/pkgdown/blob/04d3a76892320ac4bd918b39604c157e9f83507a/R/utils-fs.R#L85
4949
pkg_file <- function(..., package = "rmarkdown", mustWork = FALSE) {
50-
if (is.null(devtools_meta(package))) {
51-
system.file(..., package = package, mustWork = mustWork)
52-
} else {
50+
if (devtools_loaded(package)) {
5351
# used only if package has been loaded with devtools or pkgload
54-
file.path(getNamespaceInfo(package, "path"), "inst", ...)
52+
file.path(find.package(package), "inst", ...)
53+
} else {
54+
system.file(..., package = package, mustWork = mustWork)
5555
}
5656
}
5757

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

567567
# devtools metadata -------------------------------------------------------
568568

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

572-
devtools_meta <- function(package) {
573-
ns <- .getNamespace(package)
574-
ns[[".__DEVTOOLS__"]]
572+
devtools_loaded <- function(x) {
573+
if (!x %in% loadedNamespaces()) {
574+
return(FALSE)
575+
}
576+
ns <- .getNamespace(x)
577+
!is.null(ns$.__DEVTOOLS__)
575578
}

R/word_document.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#'
1212
#' R Markdown documents also support citations. You can find more information on
1313
#' the markdown syntax for citations in the
14-
#' \href{https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html}{Bibliographies
14+
#' \href{https://pandoc.org/MANUAL.html#citations}{Bibliographies
1515
#' and Citations} article in the online documentation.
1616
#' @inheritParams pdf_document
1717
#' @inheritParams html_document

man/beamer_presentation.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/context_document.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/convert_ipynb.Rd

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/html_document.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/md_document.Rd

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/odt_document.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/pdf_document.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rtf_document.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/word_document.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/pandoc.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Converting bib file is working
2+
3+
list(list(author = list(list(family = "Conceição", given = "Sérgio")),
4+
"container-title" = "Portuguese History", id = "conc2021",
5+
issue = "1", issued = list("date-parts" = list(list(2021L))),
6+
title = "História da habitação", type = "article-journal"))
7+
8+
---
9+
10+
[1] "["
11+
[2] " {"
12+
[3] " \"author\": ["
13+
[4] " {"
14+
[5] " \"family\": \"Conceição\","
15+
[6] " \"given\": \"Sérgio\""
16+
[7] " }"
17+
[8] " ],"
18+
[9] " \"container-title\": \"Portuguese History\","
19+
[10] " \"id\": \"conc2021\","
20+
[11] " \"issue\": \"1\","
21+
[12] " \"issued\": {"
22+
[13] " \"date-parts\": ["
23+
[14] " ["
24+
[15] " 2021"
25+
[16] " ]"
26+
[17] " ]"
27+
[18] " },"
28+
[19] " \"title\": \"História da habitação\","
29+
[20] " \"type\": \"article-journal\""
30+
[21] " }"
31+
[22] "]"
32+
33+
---
34+
35+
[1] "---"
36+
[2] "nocite: \"[@*]\""
37+
[3] "references:"
38+
[4] "- author:"
39+
[5] " - family: Conceição"
40+
[6] " given: Sérgio"
41+
[7] " container-title: Portuguese History"
42+
[8] " id: conc2021"
43+
[9] " issue: 1"
44+
[10] " issued: 2021"
45+
[11] " title: História da habitação"
46+
[12] " type: article-journal"
47+
[13] "---"
48+
[14] ""
49+

tests/testthat/resources/UTF8.bib

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@article{conc2021,
2+
title={História da Habitação},
3+
author={Conceição, Sérgio},
4+
journal={Portuguese History},
5+
number={1},
6+
year={2021}
7+
}

0 commit comments

Comments
 (0)