Skip to content

Commit

Permalink
Merged with latest changes from RStudio.
Browse files Browse the repository at this point in the history
Merge branch 'jg-tree-fix' into jg-devel

* jg-tree-fix:
  Use latest Pandoc  in GHA and update workflow (rstudio#2244)
  Add class to book cover to size using CSS
  fix the syntax highlighting of |> in LaTeX/PDF output: rstudio/bookdown#1157 (rstudio#2228)
  Add an option to opt-out the header-attrs HTML dependency in `html_document_base()` (rstudio#2227)
  Clean up NEWS.md.

# Conflicts:
#	DESCRIPTION
#	NEWS.md
  • Loading branch information
jonathan-g committed Nov 29, 2021
2 parents f0cdc81 + 10da592 commit 1a2f70a
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 129 deletions.
67 changes: 17 additions & 50 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,33 @@ jobs:
matrix:
config:
# testing R release with last shipped pandoc version in RStudio IDE and new pandoc
# TODO: issue on windows with pandoc 2.11.4 - change when fixed
- {os: windows-latest, pandoc: '2.7.3', r: 'release'}
- {os: macOS-latest, pandoc: '2.11.4', r: 'release'}
- {os: ubuntu-18.04, pandoc: '2.11.4', r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, pandoc: 'devel', r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: windows-latest, pandoc: '2.16.1', r: 'release'}
- {os: macOS-latest, pandoc: '2.16.1', r: 'release'}
- {os: ubuntu-18.04, pandoc: '2.16.1', r: 'release'}
- {os: ubuntu-18.04, pandoc: 'devel', r: 'release'}
# testing older pandoc versions
- {os: ubuntu-18.04, pandoc: '2.7.3', r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, pandoc: '2.5', r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, pandoc: '2.0.0.1', r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, pandoc: '2.14.2', r: 'release'}
- {os: ubuntu-18.04, pandoc: '2.11.4', r: 'release'}
- {os: ubuntu-18.04, pandoc: '2.7.3', r: 'release'}
- {os: ubuntu-18.04, pandoc: '2.5', r: 'release'}
- {os: ubuntu-18.04, pandoc: '2.0.0.1', r: 'release'}
# testing other R versions
- {os: ubuntu-18.04, pandoc: '2.11.4', r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, pandoc: '2.11.4', r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
- {os: ubuntu-18.04, pandoc: '2.11.4', r: 'oldrel'}
- {os: ubuntu-18.04, pandoc: '2.11.4', r: 'devel', http-user-agent: 'release'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
id: install-r
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- name: change temp dir
if: runner.os == 'Windows'
Expand All @@ -79,52 +80,18 @@ jobs:
cat(readLines("~/.Rprofile"), sep = "\n")
shell: Rscript {0}

- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v1
with:
path: |
${{ env.R_LIBS_USER }}/*
!${{ env.R_LIBS_USER }}/pak
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("rcmdcheck", execute = TRUE)
shell: Rscript {0}
extra-packages: rcmdcheck

- name: Install dependencies
- name: Pandoc and Tinytex info
run: |
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- .packages(TRUE)
sessioninfo::session_info(pkgs, include_base = TRUE)
rmarkdown::find_pandoc()
tinytex::tlmgr("--version")
tinytex::tl_pkgs()
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_TESTS_NLINES_: 0
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
- uses: r-lib/actions/check-r-package@v1

- name: Show testthat output
if: always()
Expand Down
49 changes: 8 additions & 41 deletions .github/workflows/check-pandoc-daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ jobs:
config:
- {os: windows-latest}
- {os: macOS-latest}
- {os: ubuntu-18.04, rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
id: install-r
with:
use-public-rspm: true

- name: change temp dir
if: runner.os == 'Windows'
Expand All @@ -50,52 +51,18 @@ jobs:
cat(readLines("~/.Rprofile"), sep = "\n")
shell: Rscript {0}

- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v1
with:
path: |
${{ env.R_LIBS_USER }}/*
!${{ env.R_LIBS_USER }}/pak
key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("rcmdcheck", execute = TRUE)
shell: Rscript {0}
extra-packages: rcmdcheck

- name: Install dependencies
- name: Pandoc and Tinytex info
run: |
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- .packages(TRUE)
sessioninfo::session_info(pkgs, include_base = TRUE)
rmarkdown::find_pandoc()
tinytex::tlmgr("--version")
tinytex::tl_pkgs()
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_TESTS_NLINES_: 0
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
- uses: r-lib/actions/check-r-package@v1

- name: Show testthat output
if: always()
Expand Down
34 changes: 7 additions & 27 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,22 @@ jobs:
if: ${{ github.event_name == 'push' || startsWith(github.head_ref, 'pkgdown/') }}
runs-on: ubuntu-18.04
env:
RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
id: install-r
with:
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v1

- name: Install pak and query dependencies
run: |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ runner.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("pkgdown", execute = TRUE)
shell: Rscript {0}

- name: Install package and dependencies
run: |
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("r-lib/pkgdown")
pak::pkg_install("rstudio/quillt")
shell: Rscript {0}
extra-packages: |
r-lib/pkgdown
rstudio/quillt
needs: website

- name: Install package
run: R CMD INSTALL .
Expand Down
2 changes: 1 addition & 1 deletion 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.11.2.9000
Version: 2.11.3.9000
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ rmarkdown 2.12
<dir>". This makes it possible to have a directory structure for HTML output
where there is a shared master library with css, javascript, etc. and separate
child directories with RMarkdown files. #146 and #1859.

- Added a global option `rmarkdown.html_dependency.header_attr` (`TRUE` by default). It can be set to `FALSE` to opt-out the HTML dependency `html_dependency_header_attrs()` in documents based on `html_document_base()` (thanks, @salim-b rstudio/bookdown#865, @maelle r-lib/downlit#1538).

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

rmarkdown 2.11
Expand Down
16 changes: 9 additions & 7 deletions R/html_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,14 @@ html_dependency_rsiframe <- function() {
# Pandoc 2.9 adds attributes on both headers and their parent divs. We remove
# the ones on headers since they are unnecessary (#1723).
html_dependency_header_attrs <- function() {
if (pandoc_available('2.9')) list(
htmlDependency(
"header-attrs",
version = packageVersion("rmarkdown"),
src = pkg_file("rmd/h/pandoc"),
script = "header-attrs.js"
if (getOption('rmarkdown.html_dependency.header_attr', TRUE) && pandoc_available('2.9')) {
list(
htmlDependency(
"header-attrs",
version = packageVersion("rmarkdown"),
src = pkg_file("rmd/h/pandoc"),
script = "header-attrs.js"
)
)
)
}
}
12 changes: 12 additions & 0 deletions R/pdf_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ pdf_document <- function(toc = FALSE,
output_dir)
}

post_processor <- function(metadata, input_file, output_file, clean, verbose) {
# TODO: remove this temporary fix after the syntax highlighting problem is
# fixed in Pandoc https://github.com/rstudio/bookdown/issues/1157
x <- read_utf8(output_file)
s <- '\\SpecialCharTok{|}\\ErrorTok{\\textgreater{}}'
if (length(grep(s, x, fixed = TRUE)) == 0) return(output_file)
x <- gsub(s, '\\SpecialCharTok{|\\textgreater{}}', x, fixed = TRUE)
write_utf8(x, output_file)
output_file
}

intermediates_generator <- function(...) {
general_intermediates_generator(saved_files_dir, ...)
}
Expand All @@ -207,6 +218,7 @@ pdf_document <- function(toc = FALSE,
keep_md = keep_md,
df_print = df_print,
pre_processor = pre_processor,
post_processor = post_processor,
intermediates_generator = intermediates_generator
)
}
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ R Markdown documents can be rendered to many output formats including HTML docum

## Books


<a href="https://bookdown.org/yihui/rmarkdown/"><img src="https://bookdown.org/yihui/rmarkdown/images/cover.png" alt="R Markdown: The Definitive Guide" height="400"></a>
<a href="https://bookdown.org/yihui/rmarkdown-cookbook/"><img src="https://bookdown.org/yihui/rmarkdown-cookbook/images/cover.png" alt="R Markdown Cookbook" height="400"></a>
<a href="https://bookdown.org/yihui/rmarkdown/"><img class="book" src="https://bookdown.org/yihui/rmarkdown/images/cover.png" alt="R Markdown: The Definitive Guide" height="400"></a>
<a href="https://bookdown.org/yihui/rmarkdown-cookbook/"><img class="book" src="https://bookdown.org/yihui/rmarkdown-cookbook/images/cover.png" alt="R Markdown Cookbook" height="400"></a>

See more about them in [Get Started](https://pkgs.rstudio.com/rmarkdown/articles/rmarkdown.html).

Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-html_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,8 @@ test_that("html_dependencies_fonts loads the correct fonts dep", {
expect_identical(html_dependencies_fonts(FALSE, TRUE), list(io))
expect_identical(html_dependencies_fonts(TRUE, TRUE), list(fa, io))
})

test_that("header-attr can be opt-out", {
withr::local_options(list(rmarkdown.html_dependency.header_attr = FALSE))
expect_null(html_dependency_header_attrs())
})

0 comments on commit 1a2f70a

Please sign in to comment.