diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index eed11db0a5..69b1bc42a6 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -28,22 +28,23 @@ jobs: matrix: config: # testing R release with last shipped pandoc version in RStudio IDE and new pandoc - - {os: windows-latest, pandoc: '2.16.2', r: 'release'} - - {os: macOS-latest, pandoc: '2.16.2', r: 'release'} - - {os: ubuntu-18.04, pandoc: '2.16.2', r: 'release'} + - {os: windows-latest, pandoc: '2.18', r: 'release'} + - {os: macOS-latest, pandoc: '2.18', r: 'release'} + - {os: ubuntu-18.04, pandoc: '2.18', r: 'release'} - {os: ubuntu-18.04, pandoc: 'devel', r: 'release'} # testing older pandoc versions + - {os: ubuntu-18.04, pandoc: '2.17.1.1', r: 'release'} - {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: 'devel', http-user-agent: 'release'} - - {os: ubuntu-18.04, pandoc: '2.11.4', r: 'oldrel-1'} - - {os: ubuntu-18.04, pandoc: '2.11.4', r: 'oldrel-2'} - - {os: ubuntu-18.04, pandoc: '2.11.4', r: 'oldrel-3'} - - {os: ubuntu-18.04, pandoc: '2.11.4', r: 'oldrel-4'} + - {os: ubuntu-18.04, pandoc: '2.14.2', r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-18.04, pandoc: '2.14.2', r: 'oldrel-1'} + - {os: ubuntu-18.04, pandoc: '2.14.2', r: 'oldrel-2'} + - {os: ubuntu-18.04, pandoc: '2.14.2', r: 'oldrel-3'} + - {os: ubuntu-18.04, pandoc: '2.14.2', r: 'oldrel-4'} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true diff --git a/tests/testthat/_snaps/pandoc-2.11.2/lua-filters.md b/tests/testthat/_snaps/after-pandoc-2.11.2/lua-filters.md similarity index 100% rename from tests/testthat/_snaps/pandoc-2.11.2/lua-filters.md rename to tests/testthat/_snaps/after-pandoc-2.11.2/lua-filters.md diff --git a/tests/testthat/_snaps/after-pandoc-2.18/github_document/github-toc-numbered.md b/tests/testthat/_snaps/after-pandoc-2.18/github_document/github-toc-numbered.md new file mode 100644 index 0000000000..0574938f27 --- /dev/null +++ b/tests/testthat/_snaps/after-pandoc-2.18/github_document/github-toc-numbered.md @@ -0,0 +1,11 @@ + +- 1 Section +- 2 Header + +# 1 Section + +Sentence. + +# 2 Header + +Sentence diff --git a/tests/testthat/_snaps/after-pandoc-2.18/github_document/github-toc.md b/tests/testthat/_snaps/after-pandoc-2.18/github_document/github-toc.md new file mode 100644 index 0000000000..2db2713de0 --- /dev/null +++ b/tests/testthat/_snaps/after-pandoc-2.18/github_document/github-toc.md @@ -0,0 +1,11 @@ + +- 10 Section +- Header + +# 10 Section + +Sentence. + +# Header + +Sentence diff --git a/tests/testthat/_snaps/after-pandoc-2.18/lua-filters.md b/tests/testthat/_snaps/after-pandoc-2.18/lua-filters.md new file mode 100644 index 0000000000..d3429787f6 --- /dev/null +++ b/tests/testthat/_snaps/after-pandoc-2.18/lua-filters.md @@ -0,0 +1,44 @@ +# number_sections Lua filter works + + # 1 A + + ## 1.1 B + + # 2 C + + ## 2.1 D + + See [A](#a) + +--- + + # 1 A + + ## 1.1 B + + # 2 C + + ## 2.1 D + + See [A](#1-a) + +--- + + Test + ================ + + - 1 A + - 1.1 B + - 2 C + - 2.1 D + + # 1 A + + ## 1.1 B + + # 2 C + + ## 2.1 D + + See [A](#1-a) + diff --git a/tests/testthat/_snaps/pandoc-before-2.11.2/lua-filters.md b/tests/testthat/_snaps/before-pandoc-2.11.2/lua-filters.md similarity index 53% rename from tests/testthat/_snaps/pandoc-before-2.11.2/lua-filters.md rename to tests/testthat/_snaps/before-pandoc-2.11.2/lua-filters.md index b15cded3e0..2ae99205b2 100644 --- a/tests/testthat/_snaps/pandoc-before-2.11.2/lua-filters.md +++ b/tests/testthat/_snaps/before-pandoc-2.11.2/lua-filters.md @@ -30,3 +30,23 @@ See [A](#1-a) +--- + + Test + ================ + + - [1 A](#1-a) + - [1.1 B](#11-b) + - [2 C](#2-c) + - [2.1 D](#21-d) + + # 1 A + + ## 1.1 B + + # 2 C + + ## 2.1 D + + See [A](#1-a) + diff --git a/tests/testthat/_snaps/before-pandoc-2.18/github_document/github-toc-numbered.md b/tests/testthat/_snaps/before-pandoc-2.18/github_document/github-toc-numbered.md new file mode 100644 index 0000000000..6341990a24 --- /dev/null +++ b/tests/testthat/_snaps/before-pandoc-2.18/github_document/github-toc-numbered.md @@ -0,0 +1,11 @@ + +- [1 Section](#1-section) +- [2 Header](#2-header) + +# 1 Section + +Sentence. + +# 2 Header + +Sentence diff --git a/tests/testthat/_snaps/before-pandoc-2.18/github_document/github-toc.md b/tests/testthat/_snaps/before-pandoc-2.18/github_document/github-toc.md new file mode 100644 index 0000000000..62c51e2b6a --- /dev/null +++ b/tests/testthat/_snaps/before-pandoc-2.18/github_document/github-toc.md @@ -0,0 +1,11 @@ + +- [10 Section](#10-section) +- [Header](#header) + +# 10 Section + +Sentence. + +# Header + +Sentence diff --git a/tests/testthat/_snaps/github_document/github-toc-numbered.md b/tests/testthat/_snaps/github_document/github-toc-numbered.md index 6341990a24..0574938f27 100644 --- a/tests/testthat/_snaps/github_document/github-toc-numbered.md +++ b/tests/testthat/_snaps/github_document/github-toc-numbered.md @@ -1,6 +1,6 @@ -- [1 Section](#1-section) -- [2 Header](#2-header) +- 1 Section +- 2 Header # 1 Section diff --git a/tests/testthat/_snaps/github_document/github-toc.md b/tests/testthat/_snaps/github_document/github-toc.md index 62c51e2b6a..2db2713de0 100644 --- a/tests/testthat/_snaps/github_document/github-toc.md +++ b/tests/testthat/_snaps/github_document/github-toc.md @@ -1,6 +1,6 @@ -- [10 Section](#10-section) -- [Header](#header) +- 10 Section +- Header # 10 Section diff --git a/tests/testthat/test-github_document.R b/tests/testthat/test-github_document.R index ec30e9bd9b..c256618c54 100644 --- a/tests/testthat/test-github_document.R +++ b/tests/testthat/test-github_document.R @@ -7,8 +7,9 @@ test_that("toc has correct identifier", { tmp_file <- local_rmd_file( c("# 10 Section","","Sentence.","", "# Header","","Sentence ") ) + pandoc_version <- ifelse(pandoc_available("2.18"), "after-pandoc-2.18", "before-pandoc-2.18") res <- render(tmp_file, github_document(toc = TRUE, html_preview = FALSE)) - expect_snapshot_file(res, "github-toc.md", compare = compare_file_text) + expect_snapshot_file(res, "github-toc.md", compare = compare_file_text, variant = pandoc_version) }) test_that("toc has correct identifier also when sections are numbered ", { @@ -17,8 +18,9 @@ test_that("toc has correct identifier also when sections are numbered ", { tmp_file <- local_rmd_file( c("# Section","","Sentence.","", "# Header","","Sentence ") ) + pandoc_version <- ifelse(pandoc_available("2.18"), "after-pandoc-2.18", "before-pandoc-2.18") res <- render(tmp_file, github_document(toc = TRUE, number_sections = TRUE, html_preview = FALSE)) - expect_snapshot_file(res, "github-toc-numbered.md", compare = compare_file_text) + expect_snapshot_file(res, "github-toc-numbered.md", compare = compare_file_text, variant = pandoc_version) }) diff --git a/tests/testthat/test-lua-filters.R b/tests/testthat/test-lua-filters.R index 4b4091f1c5..02e1fb5c7b 100644 --- a/tests/testthat/test-lua-filters.R +++ b/tests/testthat/test-lua-filters.R @@ -34,10 +34,16 @@ test_that("number_sections Lua filter works", { headers <- c("# A", "## B", "# C", "## D") rmd <- c(paste0(headers, "\n\n"), "See [A]") # Variant for snapshot: pandoc 2.11.2 default to atx headers - pandoc_2.11.2 <- ifelse(pandoc_available("2.11.2"), "pandoc-2.11.2", "pandoc-before-2.11.2") + pandoc_versions <- if (pandoc_available("2.18")) { + "after-pandoc-2.18" + } else if (pandoc_available("2.11.2")) { + "after-pandoc-2.11.2" + } else { + "before-pandoc-2.11.2" + } # -gfm_auto_identifiers result <- .generate_md_and_convert(rmd, md_document(number_sections = TRUE)) - expect_snapshot_output(result, variant = pandoc_2.11.2) + expect_snapshot_output(result, variant = pandoc_versions) # +gfm_auto_identifiers skip_if_not_pandoc("2.5") # gfm_auto_identifiers is not working the same before @@ -45,12 +51,12 @@ test_that("number_sections Lua filter works", { rmd, md_document(number_sections = TRUE, md_extensions = "+gfm_auto_identifiers") ) - expect_snapshot_output(result, variant = pandoc_2.11.2) + expect_snapshot_output(result, variant = pandoc_versions) # Github document skip_if_not_pandoc("2.10.1") # changes in gfm writer break this test for earlier versions result <- .generate_md_and_convert(rmd, github_document(number_sections = TRUE, toc = TRUE)) - expect_snapshot_output(result, variant = pandoc_2.11.2) + expect_snapshot_output(result, variant = pandoc_versions) }) test_that("latex-divs.lua works with HTML doc", {