Skip to content

Commit d01420e

Browse files
committed
fix #2602: --highlight-style was also deprecated
1 parent 4cc27cc commit d01420e

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: rmarkdown
33
Title: Dynamic Documents for R
4-
Version: 2.30
4+
Version: 2.30.1
55
Authors@R: c(
66
person("JJ", "Allaire", , "[email protected]", role = "aut"),
77
person("Yihui", "Xie", , "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0645-5666")),

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
rmarkdown 2.31
2+
================================================================================
3+
4+
- Use the argument `--syntax-highlighting` for Pandoc >= 3.8 since `--highlight-style` has been deprecated (thanks, @ywwry66, #2602).
5+
6+
17
rmarkdown 2.30
28
================================================================================
39

R/github_document.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ github_document <- function(toc = FALSE,
142142
"rmarkdown/templates/github_document/resources/github.css")
143143
# provide a preview that looks like github
144144
args <- c(
145-
self_contained_args(), "--highlight-style", "pygments",
145+
self_contained_args(), pandoc_highlight_args("pygments"),
146146
"--template", pkg_file_arg(
147147
"rmarkdown/templates/github_document/resources/preview.html"),
148148
"--variable", paste0("github-markdown-css:", css),

R/pandoc.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,13 @@ pandoc_include_args <- function(in_header = NULL,
309309
#' @rdname pandoc_args
310310
#' @export
311311
pandoc_highlight_args <- function(highlight, default = "tango") {
312+
p38 <- pandoc_available("3.8")
312313
if (is.null(highlight)) {
313-
if (pandoc_available("3.8")) "--syntax-highlighting=none" else "--no-highlight"
314-
} else {
315-
c("--highlight-style", if (identical(highlight, "default")) default else highlight)
314+
if (!p38) return("--no-highlight")
315+
highlight <- "none"
316316
}
317+
if (identical(highlight, "default")) highlight <- default
318+
c(if (p38) "--syntax-highlighting" else "--highlight-style", highlight)
317319
}
318320

319321
#' @rdname pandoc_args

tests/testthat/test-pandoc.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
test_that("build highlight args for pandoc correctly", {
2-
hl_style <- function(name) c("--highlight-style", name)
3-
expect_equal(pandoc_highlight_args(NULL), if (pandoc_available("3.8")) "--syntax-highlighting=none" else "--no-highlight")
4-
expect_equal(pandoc_highlight_args("default"), hl_style("tango"))
5-
expect_equal(pandoc_highlight_args("default", "zenburn"), hl_style("zenburn"))
6-
expect_equal(pandoc_highlight_args("zenburn"), hl_style("zenburn"))
2+
expect_equal(pandoc_highlight_args(NULL), if (pandoc_available("3.8")) c("--syntax-highlighting", "none") else "--no-highlight")
3+
expect_equal(pandoc_highlight_args("default")[2], "tango")
4+
expect_equal(pandoc_highlight_args("default", "zenburn")[2], "zenburn")
5+
expect_equal(pandoc_highlight_args("zenburn")[2], "zenburn")
76
})
87

98
test_that("Detect if a theme file is providing in highlight", {

0 commit comments

Comments
 (0)