Skip to content

Commit

Permalink
Merge remote-tracking branch 'rstudio/master'
Browse files Browse the repository at this point in the history
* rstudio/master: (61 commits)
  make metadata available before running pre_knit (rstudio#1855)
  fix rstudio#1815: apply the lua filters pagebreak.lua and latex-div.lua to beamer_presentation
  require the data-latex attribute on fenced Div's again: rstudio#1779 (comment)
  start the next version
  CRAN release v2.3
  fold any code blocks with the class `foldable` for html_document output (rstudio#1835)
  fix rstudio#1828: add aria-hidden = "true" to empty <a> tags in highlighted code blocks generated by Pandoc to improve screen reader accessibility (rstudio#1833)
  add a news item for rstudio#1832
  roxygenize
  no need to turn on --file-scope or actually write the split content into files if the split content is of length < 2
  eliminate renumber_footnotes option
  only test two pandoc versions (devel and RStudio version) and upgrade default to 2.7.3 (rstudio#1846)
  close rstudio#1838: test more R versions on Travis (rstudio#1845)
  renumber_footnotes output format option
  add the <div class="kable-table"> only when the output format is HTML, otherwise the div will be converted to a LaTeX environment, leading to the bug https://stackoverflow.com/q/62340425/559676
  change name of file_scope argument to references_scope
  re-roxygenize
  Add `publish_site()` function for "one-button" publishing of R Markdown websites.
  Enable use of pandoc --file-scope for input files originating from multiple Rmds (rstudio#1837)
  Added missing lang attribute to ioslides_presentation template (rstudio#1841)
  ...
  • Loading branch information
jonathan-g committed Jul 7, 2020
2 parents 15580e5 + ff1b279 commit af66857
Show file tree
Hide file tree
Showing 68 changed files with 886 additions and 327 deletions.
39 changes: 26 additions & 13 deletions .travis.yml
Expand Up @@ -2,25 +2,38 @@ dist: bionic
language: r
cache:
packages: yes
pandoc_version: 2.3.1
directories:
- "$PANDOC"
pandoc_version: 2.7.3
cran: https://cran.rstudio.com

env:
global:
- _R_CHECK_TESTS_NLINES_=0
matrix:
- PANDOC_VERSION=default NETLIFY_SITE_ID=5d77c13c-e2ee-4a31-87ca-2fe657196160
- PANDOC_VERSION=latest PATH=$HOME/bin:$PATH

before_install:
- "[[ ${PANDOC_VERSION} = latest ]] && ./tools/install-pandoc.sh || true"
- pandoc --version
- tlmgr install units

after_success:
- "[[ ${TRAVIS_BRANCH} = master ]] || exit 0"
- "[[ ${PANDOC_VERSION} = default ]] || exit 0"
- "[[ -z ${NETLIFY_AUTH_TOKEN} ]] && exit 0"
- nvm install stable
- npm install netlify-cli -g
- Rscript -e 'pkgdown::build_site(".", document = FALSE, preview = FALSE)' && netlify deploy --prod --dir docs
jobs:
include:
- r: 3.3
- r: 3.4
- r: 3.5
- r: 3.6
- r: release
name: R release / Pandoc devel
env: PATH=$HOME/bin:$PATH
before_install:
- ./tools/install-pandoc.sh || true
- pandoc --version
- r: release
name: R release / RStudio Pandoc
env: NETLIFY_SITE_ID=5d77c13c-e2ee-4a31-87ca-2fe657196160
after_success:
- "[[ ${TRAVIS_BRANCH} = master ]] || exit 0"
- "[[ -z ${NETLIFY_AUTH_TOKEN} ]] && exit 0"
- nvm install stable
- npm install netlify-cli -g
- Rscript -e 'pkgdown::build_site(".", document = FALSE, preview = FALSE)' && netlify deploy --prod --dir docs
- r: devel

8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: rmarkdown
Type: Package
Title: Dynamic Documents for R
Version: 2.0.5
Version: 2.3.2
Authors@R: c(
person("JJ", "Allaire", role = "aut", email = "jj@rstudio.com"),
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
Expand Down Expand Up @@ -30,7 +30,7 @@ Authors@R: c(
person("Sergio", "Oller", role = "ctb"),
#
# Copyright holders
person(family = "RStudio, Inc.", role = "cph"),
person(family = "RStudio, PBC", role = "cph"),
person(family = "jQuery Foundation", role = "cph",
comment = "jQuery library"),
person(family = "jQuery contributors", role = c("ctb", "cph"),
Expand Down Expand Up @@ -101,11 +101,11 @@ Suggests:
tibble,
fs,
pkgdown,
callr (>= 2.0.0)
rsconnect
SystemRequirements: pandoc (>= 1.12.3) - http://pandoc.org
URL: https://github.com/rstudio/rmarkdown
BugReports: https://github.com/rstudio/rmarkdown/issues
License: GPL-3
RoxygenNote: 7.0.2
RoxygenNote: 7.1.0
Encoding: UTF-8
VignetteBuilder: knitr
3 changes: 3 additions & 0 deletions NAMESPACE
Expand Up @@ -15,6 +15,7 @@ export(default_output_format)
export(default_site_generator)
export(draft)
export(find_external_resources)
export(find_pandoc)
export(from_rmarkdown)
export(github_document)
export(html_dependency_bootstrap)
Expand Down Expand Up @@ -61,6 +62,7 @@ export(pandoc_exec)
export(pandoc_highlight_args)
export(pandoc_include_args)
export(pandoc_latex_engine_args)
export(pandoc_metadata_arg)
export(pandoc_options)
export(pandoc_path_arg)
export(pandoc_self_contained_html)
Expand All @@ -71,6 +73,7 @@ export(pandoc_version)
export(parse_html_notebook)
export(pdf_document)
export(powerpoint_presentation)
export(publish_site)
export(relative_to)
export(render)
export(render_delayed)
Expand Down
65 changes: 65 additions & 0 deletions NEWS.md
@@ -1,6 +1,69 @@
rmarkdown 2.4
================================================================================

- Since **rmarkdown** 1.16, Pandoc's fenced `Div`'s are converted to LaTeX environments when the output format is LaTeX, e.g., `::: {.center data-latex=""}` is converted to `\begin{center}`. The attribute `data-latex` of the `Div` was mandatory, even if it is empty. In **rmarkdown** 2.2, we silently drop this requirement, which means `::: {.center}` is converted to `\begin{center}`. This turns out to be a bad idea, because users have no control over which Div's to be converted to LaTeX environments. Previously, they could opt-in by the `data-latex` attribute, but with **rmarkdown** 2.3, all Div's are converted to LaTeX environments unconditionally. What's more, this change led to bugs like https://stackoverflow.com/q/62340425/559676 and https://github.com/rstudio/bookdown/issues/883. Therefore the `data-latex` attribute became mandatory again in this version. If the LaTeX environment does not need arguments, you may use `data-latex=""`.

- The two Lua fitlers `pagebreak.lua` and `latex-div.lua` (introduced in **rmarkdown** 1.16) are also applied to the output format `beamer_presentation` now (thanks, @XiangyunHuang, #1815).

- When customizing formats with the `output_format` function, `pre_knit`, `opts_hooks`, and `knit_hooks` can now refer to `rmarkdown::metadata`. Previously, `rmarkdown::metadata` returned `list()` in these functions (thanks, @atusy, #1855).

rmarkdown 2.3
================================================================================

- Addressed an accessibility issue in highlighted code blocks of HTML output for screen reader users: screen readers no longer read out an unnecessary code line id values (thanks, @jooyoungseo and @atusy, #1833).

- Added `file_scope` option to output format definition. This enables handling of duplicate numeric footnote identifiers (e.g. across bookdown chapters) via the pandoc `--file-scope` option (#1837).

- Added the customizable `lang` attribute to `ioslides_presentation` output (thanks, @jooyoungseo, #1841).

- Added `publish_site()` function for "one-button" publishing of R Markdown websites.

- When the `df_print` option is `kable` and the output format is not HTML, `<div class="kable-table">` is no longer added to the `kable()` output, because recent versions of Pandoc will convert the `div` to a LaTeX environment when the output format is LaTeX (thanks, Laurens, https://stackoverflow.com/q/62340425/559676).

- `html_vignette()` only warns against differences in the vignette title and the vignette index entry for R >= 3.6.0 (thanks, @krlmlr, #1832).

- `html_document()` can apply `code_folding` on any chunk engines if the `foldable` class is added to a source code block via the chunk options (`class.source` or `attr.source`). You may apply this feature to all the source code blocks, for example, by setting `knitr::opts_chunk$set(class.source = "foldable")` at the beginning of your document (thanks, @atusy, #1835).


rmarkdown 2.2
================================================================================

- Exported the internal function `find_pandoc()`, and also added two arguments, `dir` and `version`, so that users can provide a custom directory under which this function may find Pandoc, as well as an expected version of Pandoc to be found (thanks, @connorp, #1785).

- `pandoc_metadata_arg()` is a new Pandoc helper function to generate `--metadata` argument for Pandoc command line (thanks, @cderv, #1789).

- The output format `html_vignette()` now warns against differences in the vignette title specified in the `title` field in the YAML metadata and the one specified inside `\VignetteIndexEntry{}`. Normally they are expected to be identical (#1789).

- Fixed a bug with encoding when rendering `html_notebook` containing HTML widgets (thanks, @cderv, #1799).

- TOC title can now be specified for `html_document` via the top-level option `toc-title` in the YAML frontmatter (thanks, @atusy, #1771).

- Floating TOC can now distinguish upper/lower-cases (thanks, @atusy, #1783).

- When `code_folding='show'` for the output format `html_document`, code blocks can be individually hidden initially by specifying the chunk option `class.source='fold-hide'` (thanks, @atusy, #1798).

- For LaTeX/PDF output formats `pdf_document`, `beamer_presentation`, and `context_document`, the argument `citation_package = 'none'` was deprecated, and `citation_package = 'default'` should be used instead if citations are to be processed by `pandoc-citeproc` (thanks, @njbart, rstudio/bookdown#754).

- `output_format()` can now inherit `keep_md` and `clean_supporting` from `base_format` when `NULL` is passed to these arguments. Previously, you must explicitly specify `keep_md` and/or `clean_supporting` as `TRUE` or `FALSE` in `output_format()` since they could not inherit the corresponding options of `base_format`. This behavior was not consisent with other arguments of `output_format()` (thanks, @atusy, #1823).

- The `smart` argument of most output formats has been removed, because Pandoc's `smart` extension is enabled by default, and setting `smart: false` for an output format did not really have any effect (which could be considered a bug, but we want to get rid of this option since it existed only for a historical reason for Pandoc 1.x, and Pandoc 2.x has been released for more than two years). If you want to disable the `smart` extension, you can use the option `md_extensions: -smart` of the output format (thanks, @atusy, #1774).

- `pdf_document()` should not specify the `geometry` variable when the `documentclass` variable is passed to Pandoc (thanks, @jpcirrus, #1782).

- `render()` now respects the YAML metadata in the R script when rendering the script with Pandoc 2.8 or later (thanks, @nsoranzo #1740, @cderv #1741).

- For `pandoc_convert()`, when the argument `to = 'pdf'`, it will be changed to `'latex'` internally (thanks, @JohannesFriedrich, #1802).

- `render(run_pandoc = FALSE)` no longer cleans up the Markdown file (typically knitted from Rmd) (thanks, @BrianDiggs, #1812).


rmarkdown 2.1
================================================================================

- Added the returned output from `shiny::runApp()` within `rmarkdown::run()` (thanks, @schloerke, #1760).

- YAML header is now correctly parsed in `html_notebook`'s intermediate `.knit.md` file so that features like adding bibliography works again (thanks, @everdark, @cderv, #1747).

- `ioslides_presentation` template no longer generates an empty `<h2>` tag when `subtitle` is not specified in YAML (thanks, @jooyoungseo #1735, @cgrudz #1663).

- No longer center the `#header` element in the `html_vignette()` output (thanks, @EmilHvitfeldt, #1742).
Expand All @@ -11,6 +74,8 @@ rmarkdown 2.1

- Removed the jQuery dependency in `html_document_base()` (#1723). To avoid bugs like #1723, Pandoc 2.8 users have to upgrade to Pandoc 2.9+.

- For `pdf_document`, horizontal rules generated by Pandoc (before v2.8) stopped working in recent versions of TeX Live, and the same fix as the one to https://github.com/jgm/pandoc/issues/5801 (i.e., hard-code `\linethickness` to `0.5pt`) was applied in **rmarkdown** (thanks, @cderv, https://stackoverflow.com/a/58646915/559676).


rmarkdown 2.0
================================================================================
Expand Down
7 changes: 4 additions & 3 deletions R/beamer_presentation.R
Expand Up @@ -66,7 +66,7 @@ beamer_presentation <- function(toc = FALSE,
keep_tex = FALSE,
keep_md = FALSE,
latex_engine = "pdflatex",
citation_package = c("none", "natbib", "biblatex"),
citation_package = c("default", "natbib", "biblatex"),
self_contained = TRUE,
includes = NULL,
md_extensions = NULL,
Expand Down Expand Up @@ -115,8 +115,7 @@ beamer_presentation <- function(toc = FALSE,
args <- c(args, pandoc_latex_engine_args(latex_engine))

# citation package
citation_package <- match.arg(citation_package)
if (citation_package != "none") args <- c(args, paste0("--", citation_package))
args <- c(args, citation_package_arg(citation_package))

# generate a self-contained LaTeX document (including preamble)
if (self_contained) args <- c(args, "--self-contained")
Expand All @@ -127,6 +126,8 @@ beamer_presentation <- function(toc = FALSE,
# make sure the graphics package is always loaded
if (identical(template, "default")) args <- c(args, "--variable", "graphics=yes")

args <- c(args, pandoc_lua_filters(c("pagebreak.lua", "latex-div.lua")))

# custom args
args <- c(args, pandoc_args)

Expand Down
3 changes: 1 addition & 2 deletions R/context_document.R
Expand Up @@ -85,8 +85,7 @@ context_document <- function(toc = FALSE,
args <- c(args, "--template", pandoc_path_arg(template))

# citation package
citation_package <- match.arg(citation_package)
if (citation_package != "none") args <- c(args, paste0("--", citation_package))
args <- c(args, citation_package_arg(citation_package))

# content includes
args <- c(args, includes_to_pandoc_args(includes))
Expand Down
12 changes: 12 additions & 0 deletions R/html_dependencies.R
Expand Up @@ -71,6 +71,18 @@ html_dependency_tocify <- function() {
stylesheet = "jquery.tocify.css")
}

# Create an HTML dependency for Pandoc code block accessibility
html_dependency_accessible_code_block <- function() {
ver <- pandoc_version()
if (ver < '2.7.3' || ver > '2.9.2.1') return()
htmlDependency(
name = "accessible-code-block",
version = "0.0.1",
src = pkg_file("rmd/h/accessibility"),
script = "empty-anchor.js"
)
}

# Create an HTML dependency for FontAwesome
#' @rdname html-dependencies
#' @export
Expand Down
20 changes: 10 additions & 10 deletions R/html_document.R
Expand Up @@ -39,9 +39,6 @@
#' chunks by default.
#'@param code_download Embed the Rmd source code within the document and provide
#' a link that can be used by readers to download the code.
#'@param smart Produce typographically correct output, converting straight
#' quotes to curly quotes, \code{---} to em-dashes, \code{--} to en-dashes, and
#' \code{...} to ellipses.
#'@param self_contained Produce a standalone HTML file with no external
#' dependencies, using data: URIs to incorporate the contents of linked
#' scripts, stylesheets, images, and videos. Note that even for self contained
Expand Down Expand Up @@ -191,7 +188,6 @@ html_document <- function(toc = FALSE,
df_print = "default",
code_folding = c("none", "show", "hide"),
code_download = FALSE,
smart = TRUE,
self_contained = TRUE,
theme = "default",
highlight = "default",
Expand All @@ -216,8 +212,6 @@ html_document <- function(toc = FALSE,
# table of contents
args <- c(args, pandoc_toc_args(toc, toc_depth))

md_extensions <- smart_extension(smart, md_extensions)

# toc_float
if (toc && !identical(toc_float, FALSE)) {

Expand Down Expand Up @@ -285,9 +279,15 @@ html_document <- function(toc = FALSE,
args <- c(args, pandoc_html_highlight_args(template, highlight))

# add highlight.js html_dependency if required
if (identical(template, "default") && is_highlightjs(highlight)) {
extra_dependencies <- append(extra_dependencies, list(html_dependency_highlightjs(highlight)))
}
extra_dependencies <- append(
extra_dependencies,
if (identical(template, "default") && is_highlightjs(highlight)) {
list(html_dependency_highlightjs(highlight))
} else if (!is.null(highlight)) {
# for screen-reader accessibility improvement
list(html_dependency_accessible_code_block())
}
)

# numbered sections
if (number_sections)
Expand Down Expand Up @@ -439,7 +439,7 @@ html_document <- function(toc = FALSE,
post_knit = post_knit,
pre_processor = pre_processor,
on_exit = on_exit,
base_format = html_document_base(smart = smart, theme = theme,
base_format = html_document_base(theme = theme,
self_contained = self_contained,
lib_dir = lib_dir, mathjax = mathjax,
template = template,
Expand Down
11 changes: 4 additions & 7 deletions R/html_document_base.R
Expand Up @@ -7,15 +7,16 @@
#'
#' @param dependency_resolver A dependency resolver
#' @param copy_resources Copy resources
#' @param extra_dependencies Extra dependencies
#' @param extra_dependencies Extra dependencies as a list of the
#' \code{html_dependency} class objects typically generated by
#' \code{htmltools::\link{htmlDependency}()}.
#' @param bootstrap_compatible Bootstrap compatible
#' @param ... Ignored
#'
#' @return HTML base output format.
#'
#' @export
html_document_base <- function(smart = TRUE,
theme = NULL,
html_document_base <- function(theme = NULL,
self_contained = TRUE,
lib_dir = NULL,
mathjax = "default",
Expand All @@ -33,10 +34,6 @@ html_document_base <- function(smart = TRUE,

args <- c()

# smart quotes, etc.
if (smart && !pandoc2.0())
args <- c(args, "--smart")

# no email obfuscation
args <- c(args, "--email-obfuscation", "none")

Expand Down
3 changes: 1 addition & 2 deletions R/html_fragment.R
Expand Up @@ -23,7 +23,6 @@ html_fragment <- function(number_sections = FALSE,
fig_caption = TRUE,
dev = 'png',
df_print = "default",
smart = TRUE,
mathjax = TRUE,
includes = NULL,
keep_md = FALSE,
Expand All @@ -37,7 +36,7 @@ html_fragment <- function(number_sections = FALSE,
html_document(
number_sections = number_sections, fig_width = fig_width,
fig_height = fig_height, fig_retina = fig_retina, fig_caption = fig_caption,
dev = dev, df_print = df_print, smart = smart, keep_md = keep_md,
dev = dev, df_print = df_print, keep_md = keep_md,
md_extensions = md_extensions, pandoc_args = pandoc_args, includes = includes,
mathjax = NULL, section_divs = section_divs, highlight = NULL, theme = NULL, ...,
template = pkg_file("rmd/fragment/default.html")
Expand Down
2 changes: 0 additions & 2 deletions R/html_notebook.R
Expand Up @@ -25,7 +25,6 @@ html_notebook <- function(toc = FALSE,
fig_retina = 2,
fig_caption = TRUE,
code_folding = "show",
smart = TRUE,
theme = "default",
highlight = "textmate",
mathjax = "default",
Expand Down Expand Up @@ -200,7 +199,6 @@ html_notebook <- function(toc = FALSE,
fig_retina = fig_retina,
fig_caption = fig_caption,
code_folding = code_folding,
smart = smart,
theme = theme,
highlight = highlight,
mathjax = mathjax,
Expand Down
20 changes: 19 additions & 1 deletion R/html_paged.R
Expand Up @@ -205,7 +205,25 @@ paged_table_html <- function(x, options = NULL) {
#' Create a table in HTML with support for paging rows and columns
#'
#' @param x a data frame to be rendered as a paged table.
#' @param options options for printing the paged table
#' @param options options for printing the paged table. See details for specifics.
#'
#' @details
#' Below are the recognized table pagination options.
#'
#' \tabular{rll}{
#' Option \tab Description \tab Default \cr
#' \code{max.print} \tab The number of rows to print. \tab 1000 \cr
#' \code{sql.max.print} \tab The number of rows to print from a SQL data table. \tab 1000 \cr
#' \code{rows.print} \tab The number of rows to display. \tab 10 \cr
#' \code{cols.print} \tab The number of columns to display. \tab 10 \cr
#' \code{cols.min.print} \tab The minimum number of columns to display. \tab - \cr
#' \code{pages.print} \tab The number of pages to display under page navigation. \tab - \cr
#' \code{paged.print} \tab When set to FALSE turns off paged tables. \tab TRUE \cr
#' \code{rownames.print} \tab When set to FALSE turns off row names. \tab TRUE
#' }
#'
#' \bold{Note:} There is a hard cap of 10,000 rows to ensure that pandoc will not
#' fail when rendering the document.
#'
#' @export
paged_table <- function(x, options = NULL) {
Expand Down
2 changes: 1 addition & 1 deletion R/html_resources.R
Expand Up @@ -345,7 +345,7 @@ discover_rmd_resources <- function(rmd_file, discover_single_resource) {
)

# clean up output file and its supporting files directory
temp_files <- c(temp_files, html_file, knitr_files_dir(md_file))
temp_files <- c(temp_files, html_file, knitr_files_dir(md_file), knitr_files_dir(html_file))

# run the HTML resource discovery mechanism on the rendered output
discover_html_resources(html_file, discover_single_resource)
Expand Down

0 comments on commit af66857

Please sign in to comment.