diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ce6d0f02e..05728570c 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -25,20 +25,18 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, cache: '~/Library/Application Support/renv', r: 'release'} + - {os: macOS-latest, cache: '~/Library/Application Support/renv', r: 'release'} - {os: windows-latest, r: 'release'} - # Use 3.6 to trigger usage of RTools35 - - {os: windows-latest, cache: '~\AppData\Local\renv', r: '3.6'} # use 4.1 to check with rtools40's older compiler - {os: windows-latest, r: '4.1'} - - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'release', cov: 'true'} - - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'oldrel-1'} - - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'oldrel-2'} - - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'oldrel-3'} - - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'oldrel-4'} + - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'release', cov: 'true'} + - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'oldrel-1'} + - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'oldrel-2'} + - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'oldrel-3'} + - {os: ubuntu-latest, cache: '~/.local/share/renv', r: 'oldrel-4'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -62,7 +60,6 @@ jobs: - uses: actions/checkout@v3 - uses: r-lib/actions/setup-pandoc@v2 - if: runner.os != 'Windows' - name: "Windows: setup TMPDIR" if: runner.os == 'Windows' @@ -71,10 +68,6 @@ jobs: echo "TMPDIR=${{ runner.temp }}" >> $GITHUB_ENV shell: bash - - name: "Setup devel pandoc windows" - uses: cderv/actions/setup-pandoc-nightly@nightly-pandoc - if: runner.os == 'Windows' - - name: "Setup R" uses: r-lib/actions/setup-r@v2 with: @@ -90,7 +83,7 @@ jobs: - name: "Restore {renv} cache" if: runner.os != 'Windows' - uses: actions/cache@v3.0.11 + uses: actions/cache@v3 with: path: ${{ env.RENV_PATHS_ROOT }} key: ${{ runner.os }}-${{ env.OS_VERSION }}-renv-${{ runner.r }}-${{ hashFiles('.github/workflows/R-CMD-check.yaml') }} diff --git a/tests/testthat/_snaps/render_html.md b/tests/testthat/_snaps/2.19.2/render_html.md similarity index 100% rename from tests/testthat/_snaps/render_html.md rename to tests/testthat/_snaps/2.19.2/render_html.md diff --git a/tests/testthat/_snaps/3.1.1/render_html.md b/tests/testthat/_snaps/3.1.1/render_html.md new file mode 100644 index 000000000..c957e0d31 --- /dev/null +++ b/tests/testthat/_snaps/3.1.1/render_html.md @@ -0,0 +1,460 @@ +# pandoc structure is rendered correctly + + Code + cat(readLines(out), sep = "\n") + Output + [ RawBlock (Format "text") "" + , Div + ( "" , [ "overview" , "card" ] , [] ) + [ RawBlock + (Format "html") "

Overview

" + , Div + ( "" , [ "row" , "g-0" ] , [] ) + [ Div + ( "" , [ "col-md-4" ] , [] ) + [ Div + ( "" , [ "card-body" ] , [] ) + [ Div + ( "" , [ "inner" ] , [] ) + [ RawBlock + (Format "html") + "

Questions

" + , BulletList + [ [ Plain + [ Str "What\8217s" + , Space + , Str "the" + , Space + , Str "point?" + ] + ] + ] + ] + ] + ] + , Div + ( "" , [ "col-md-8" ] , [] ) + [ Div + ( "" , [ "card-body" ] , [] ) + [ Div + ( "" , [ "inner" , "bordered" ] , [] ) + [ RawBlock + (Format "html") + "

Objectives

" + , BulletList + [ [ Plain + [ Str "Bake" + , Space + , Str "him" + , Space + , Str "away," + , Space + , Str "toys" + ] + ] + ] + ] + ] + ] + ] + ] + , Header 1 ( "markdown" , [] , [] ) [ Str "Markdown" ] + , Div + ( "challenge1" , [ "callout" , "challenge" ] , [] ) + [ Div + ( "" , [ "callout-square" ] , [] ) + [ RawBlock + (Format "html") + "" + ] + , Div + ( "" , [ "callout-inner" ] , [] ) + [ Header + 3 ( "" , [ "callout-title" ] , [] ) [ Str "Challenge" ] + , Div + ( "" , [ "callout-content" ] , [] ) + [ Para + [ Str "How" + , Space + , Str "do" + , Space + , Str "you" + , Space + , Str "write" + , Space + , Str "markdown" + , Space + , Str "divs?" + ] + , Para + [ Str "This" + , Space + , Link + ( "" , [] , [] ) + [ Str "link" + , Space + , Str "should" + , Space + , Str "be" + , Space + , Str "transformed" + ] + ( "Setup.html" , "" ) + ] + , Para + [ Str "This" + , Space + , Link + ( "" , [] , [] ) + [ Str "rmd" + , Space + , Str "link" + , Space + , Str "also" + ] + ( "01-Introduction.html" , "" ) + ] + , Para + [ Str "This" + , Space + , Link + ( "" , [ "newclass" ] , [] ) + [ Str "rmd" + , Space + , Str "is" + , Space + , Str "safe" + ] + ( "https://example.com/01-Introduction.Rmd" , "" ) + ] + , Para + [ Str "This" + , Space + , Link + ( "" , [] , [] ) + [ Str "too" ] + ( "Setup.html#windows-setup" , "windows setup" ) + ] + , Figure + ( "fig-first" , [] , [] ) + (Caption + Nothing + [ Plain + [ Str "link" + , Space + , Str "should" + , Space + , Str "be" + , Space + , Str "transformed" + ] + ]) + [ Plain + [ Image + ( "" , [ "imgclass" ] , [] ) + [ Str "alt" , Space , Str "text" ] + ( "fig/Setup.png" , "" ) + ] + ] + ] + ] + ] + , Div + ( "accordionSolution1" + , [ "accordion" + , "challenge-accordion" + , "accordion-flush" + ] + , [] + ) + [ Div + ( "" , [ "accordion-item" ] , [] ) + [ RawBlock + (Format "html") + "" + , Div + ( "collapseSolution1" + , [ "accordion-collapse" , "collapse" ] + , [ ( "[Solution hidden]" ) + , ( "[Solution hidden]" ) + ] + ) + [ Div + ( "" , [ "accordion-body" ] , [] ) + [ Para + [ Str "just" + , Space + , Str "write" + , Space + , Str "it," + , Space + , Str "silly." + ] + ] + ] + ] + ] + , Div + ( "accordionInstructor1" + , [ "accordion" , "instructor-note" , "accordion-flush" ] + , [] + ) + [ Div + ( "" , [ "accordion-item" ] , [] ) + [ RawBlock + (Format "html") + "" + , Div + ( "collapseInstructor1" + , [ "accordion-collapse" , "collapse" ] + , [ ( "[Instructor hidden]" ) + , ( "[Instructor hidden]" ) + ] + ) + [ Div + ( "" , [ "accordion-body" ] , [] ) + [ Para + [ Str "This" + , Space + , Str "should" + , Space + , Str "be" + , Space + , Str "aside" + ] + ] + ] + ] + ] + , Div + ( "accordionSpoiler1" + , [ "accordion" , "spoiler-accordion" , "accordion-flush" ] + , [] + ) + [ Div + ( "" , [ "accordion-item" ] , [] ) + [ RawBlock + (Format "html") + "" + , Div + ( "collapseSpoiler1" + , [ "accordion-collapse" , "collapse" ] + , [ ( "[Spoiler hidden]" ) + , ( "[Spoiler hidden]" ) + ] + ) + [ Div + ( "" , [ "accordion-body" ] , [] ) + [ Para + [ Str "That" + , Space + , Str "fin" + , Space + , Str "on" + , Space + , Str "the" + , Space + , Str "rear" + , Space + , Str "end" + , Space + , Str "of" + , Space + , Str "a" + , Space + , Str "car" + ] + ] + ] + ] + ] + , Div + ( "" , [ "nothing" ] , [] ) + [ Para + [ Str "This" , Space , Str "should" , Space , Str "be" ] + ] + ] + +# paragraphs after objectives block are parsed correctly + + Code + cat(readLines(out), sep = "\n") + Output + [ RawBlock (Format "text") "" + , Div + ( "" , [ "overview" , "card" ] , [] ) + [ RawBlock + (Format "html") "

Overview

" + , Div + ( "" , [ "row" , "g-0" ] , [] ) + [ Div + ( "" , [ "col-md-4" ] , [] ) + [ Div + ( "" , [ "card-body" ] , [] ) + [ Div + ( "" , [ "inner" ] , [] ) + [ RawBlock + (Format "html") + "

Questions

" + , BulletList + [ [ Plain + [ Str "What\8217s" + , Space + , Str "the" + , Space + , Str "point?" + ] + ] + ] + ] + ] + ] + , Div + ( "" , [ "col-md-8" ] , [] ) + [ Div + ( "" , [ "card-body" ] , [] ) + [ Div + ( "" , [ "inner" , "bordered" ] , [] ) + [ RawBlock + (Format "html") + "

Objectives

" + , BulletList + [ [ Plain + [ Str "Bake" + , Space + , Str "him" + , Space + , Str "away," + , Space + , Str "toys" + ] + ] + ] + ] + ] + ] + ] + ] + , Para + [ Str "Do" + , Space + , Str "you" + , Space + , Str "think" + , Space + , Str "he" + , Space + , Str "saurus?" + ] + , Header 1 ( "markdown" , [] , [] ) [ Str "Markdown" ] + ] + +# render_html applies the internal lua filter + + Code + cat(res) + Output +
+

Overview

+
+
+
+
+

Questions

+
    +
  • What’s the point?
  • +
+
+
+
+
+
+
+

Objectives

+
    +
  • Bake him away, toys
  • +
+
+
+
+
+
+
+

Markdown

+
+
+ +
+
+

Challenge

+
+

How do you write markdown divs?

+

This link should be transformed

+

This rmd link also

+

This rmd is safe

+

This too

+
+ alt text +
link should be transformed
+
+
+
+
+
+
+ +
+
+

just write it, silly.

+
+
+
+
+
+
+ +
+
+

This should be aside

+
+
+
+
+
+
+ +
+
+

That fin on the rear end of a car

+
+
+
+
+
+

This should be

+
+
+ diff --git a/tests/testthat/test-render_html.R b/tests/testthat/test-render_html.R index a5878e850..e6507a700 100644 --- a/tests/testthat/test-render_html.R +++ b/tests/testthat/test-render_html.R @@ -83,16 +83,16 @@ test_that("pandoc structure is rendered correctly", { args <- construct_pandoc_args(example_markdown, out, to = "native") callr::r(function(...) rmarkdown::pandoc_convert(...), args = args) - if (.Platform$OS.type == "windows" && Sys.getenv("CI", unset = '') == "true") { - # let's see what this looks like - message(cat(readLines(out), sep = "\n")) - } - skip_on_os("windows") formation = function(x) { rgx <- "(data-bs-parent|aria-labelledby).+?(Instructor|Solution|Spoiler)1" return(sub(rgx, "[\\2 hidden]", x)) } - expect_snapshot(cat(readLines(out), sep = "\n"), transform = formation) + ver <- as.character(rmarkdown::pandoc_version()) + expect_snapshot( + cat(readLines(out), sep = "\n"), + transform = formation, + variant = ver + ) }) test_that("paragraphs after objectives block are parsed correctly", { @@ -107,12 +107,8 @@ test_that("paragraphs after objectives block are parsed correctly", { writeLines(ex2, tmp) args <- construct_pandoc_args(tmp, out, to = "native") callr::r(function(...) rmarkdown::pandoc_convert(...), args = args) - if (.Platform$OS.type == "windows" && Sys.getenv("CI", unset = '') == "true") { - # let's see what this looks like - message(cat(readLines(out), sep = "\n")) - } - skip_on_os("windows") - expect_snapshot(cat(readLines(out), sep = "\n")) + ver <- as.character(rmarkdown::pandoc_version()) + expect_snapshot(cat(readLines(out), sep = "\n"), variant = ver) }) @@ -141,11 +137,6 @@ test_that("render_html applies the internal lua filter", { expect_match(res, "div class=\"nothing\"", fixed = TRUE) expect_failure(expect_match(res, "Nothing", fixed = TRUE)) - if (.Platform$OS.type == "windows" && Sys.getenv("CI", unset = '') == "true") { - # let's see what this looks like - message(res) - } - skip_on_os("windows") formation = function(x) { open <- "[<]div id[=]\"collapse(Instructor|Solution|Spoiler)\\d\".+" mid <- "(data-bs-parent|aria-labelledby).+?(Instructor|Solution|Spoiler)\\d[\"]$" @@ -155,7 +146,8 @@ test_that("render_html applies the internal lua filter", { x <- sub(close, "...done]>", x) return(x) } - expect_snapshot(cat(res), transform = formation) + ver <- as.character(rmarkdown::pandoc_version()) + expect_snapshot(cat(res), transform = formation, variant = ver) })