diff --git a/tests/testthat/test-parse-fenced_divs.R b/tests/testthat/test-parse-fenced_divs.R index 44033bb..72e5558 100644 --- a/tests/testthat/test-parse-fenced_divs.R +++ b/tests/testthat/test-parse-fenced_divs.R @@ -173,7 +173,11 @@ And another. parse_rmd(ex1), rmd_ast( rmd_fenced_div_open(c("#special",".sidebar")), - rmd_markdown("Here is a paragraph.","","And another."), + rmd_markdown( + rmd_markdown_line("Here is a paragraph."), + rmd_markdown_line(""), + rmd_markdown_line("And another.") + ), rmd_fenced_div_close() ) ) @@ -191,9 +195,14 @@ This is a warning within a warning. parse_rmd(ex2), rmd_ast( rmd_fenced_div_open(".Warning"), - rmd_markdown("This is a warning.", ""), + rmd_markdown( + rmd_markdown_line("This is a warning."), + rmd_markdown_line("") + ), rmd_fenced_div_open(".Danger"), - rmd_markdown("This is a warning within a warning."), + rmd_markdown( + rmd_markdown_line("This is a warning within a warning.") + ), rmd_fenced_div_close(), rmd_fenced_div_close() ) diff --git a/tests/testthat/test-parse-markdown.R b/tests/testthat/test-parse-markdown.R index f043dd4..459ef67 100644 --- a/tests/testthat/test-parse-markdown.R +++ b/tests/testthat/test-parse-markdown.R @@ -3,39 +3,50 @@ test_that("markdown", { expect_identical( check_markdown_parser("test\n"), - rmd_markdown("test") + rmd_markdown( + rmd_markdown_line("test") + ) ) expect_identical( check_markdown_parser("test\ntest\n"), - rmd_markdown("test", "test") + rmd_markdown( + rmd_markdown_line("test"), + rmd_markdown_line("test") + ) ) expect_identical( check_markdown_parser("`r 1+1`\n"), rmd_markdown( - rmd_inline_code(engine = "r", code="1+1") + rmd_markdown_line( + rmd_inline_code(engine = "r", code="1+1") + ) ) ) expect_identical( check_markdown_parser("`{r} 1+1`\n"), rmd_markdown( - rmd_inline_code(engine = "r", code="1+1") + rmd_markdown_line( + rmd_inline_code(engine = "r", code="1+1") + ) ) ) expect_identical( check_markdown_parser("``r 1+1``\n"), rmd_markdown( - list("`", rmd_inline_code(engine = "r", code="1+1"), "`") + rmd_markdown_line( + "`", rmd_inline_code(engine = "r", code="1+1"), "`" + ) ) ) expect_identical( check_markdown_parser("``{r} 1+1``\n"), rmd_markdown( - list("`", rmd_inline_code(engine = "r", code="1+1"), "`") + rmd_markdown_line("`", rmd_inline_code(engine = "r", code="1+1"), "`") ) ) }) diff --git a/tests/testthat/test-parse-yaml.R b/tests/testthat/test-parse-yaml.R index 6d95f2a..891ea42 100644 --- a/tests/testthat/test-parse-yaml.R +++ b/tests/testthat/test-parse-yaml.R @@ -122,16 +122,25 @@ test_that("Pandoc - yaml metadata block", { # See https://pandoc.org/MANUAL.html expect_equal( parse_rmd("---\n\n...\n"), rmd_ast( - rmd_markdown("---","","...") + rmd_markdown( + rmd_markdown_line("---"), + rmd_markdown_line(""), + rmd_markdown_line("...") + ) ) ) expect_equal( parse_rmd("---\n\n---\n---\n...\n"), rmd_ast( - rmd_markdown("---",""), + rmd_markdown( + rmd_markdown_line("---"), + rmd_markdown_line("") + ), rmd_yaml(), - rmd_markdown("...") + rmd_markdown( + rmd_markdown_line("...") + ) ) ) @@ -139,7 +148,11 @@ test_that("Pandoc - yaml metadata block", { # See https://pandoc.org/MANUAL.html parse_rmd("---\n---\n---\n\n...\n"), rmd_ast( rmd_yaml(), - rmd_markdown("---","","...") + rmd_markdown( + rmd_markdown_line("---"), + rmd_markdown_line(""), + rmd_markdown_line("...") + ) ) ) }) diff --git a/tests/testthat/test-parse-yaml_options.R b/tests/testthat/test-parse-yaml_options.R index 849af9e..3119c7e 100644 --- a/tests/testthat/test-parse-yaml_options.R +++ b/tests/testthat/test-parse-yaml_options.R @@ -124,10 +124,10 @@ test_that("parse full document with yaml options", { title = "Using dash options in YAML options header" ), rmd_markdown( - "In Quarto, it is recommended to use YAML options format with dash in option name instead of dot. In knitr 1.44, any chunk option with dash will be transformed to its dot counterpart. This is because knitr is responsible for engine option parsing in Quarto. ", - "", - "This document checks that YAML options are parsed correctly and that dash option are correctly converted when provided in YAML. ", - "" + rmd_markdown_line("In Quarto, it is recommended to use YAML options format with dash in option name instead of dot. In knitr 1.44, any chunk option with dash will be transformed to its dot counterpart. This is because knitr is responsible for engine option parsing in Quarto. "), + rmd_markdown_line(""), + rmd_markdown_line("This document checks that YAML options are parsed correctly and that dash option are correctly converted when provided in YAML. "), + rmd_markdown_line("") ), rmd_chunk( engine = "r", diff --git a/tests/testthat/test-parse_rmd.R b/tests/testthat/test-parse_rmd.R index 509f054..bcf7171 100644 --- a/tests/testthat/test-parse_rmd.R +++ b/tests/testthat/test-parse_rmd.R @@ -3,11 +3,10 @@ test_that("minimal.Rmd", { expected_ast = rmd_ast( rmd_yaml( - 'title: "Minimal"', - 'author: "Colin Rundel"', - 'date: "7/21/2020"', - 'output: html_document', - parse = TRUE + title = "Minimal", + author = "Colin Rundel", + date = "7/21/2020", + output = "html_document" ), rmd_heading("Setup", 1), rmd_chunk( @@ -17,12 +16,12 @@ test_that("minimal.Rmd", { rmd_heading("Content", 1), rmd_heading("R Markdown", 2), rmd_markdown( - 'This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, ', - 'PDF, and MS Word documents. For more details on using R Markdown see .', - '', - 'When you click the **Knit** button a document will be generated that includes both content as well ', - 'as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:', - '' + rmd_markdown_line('This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, '), + rmd_markdown_line('PDF, and MS Word documents. For more details on using R Markdown see .'), + rmd_markdown_line(''), + rmd_markdown_line('When you click the **Knit** button a document will be generated that includes both content as well '), + rmd_markdown_line('as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:'), + rmd_markdown_line('') ), rmd_chunk( name = "cars", code = "summary(cars)" @@ -31,14 +30,17 @@ test_that("minimal.Rmd", { name = "unnamed-chunk-1", code = "knitr::knit_patterns$get()" ), rmd_heading("Including Plots", 2), - rmd_markdown("You can also embed plots, for example:", ""), + rmd_markdown( + rmd_markdown_line("You can also embed plots, for example:"), + rmd_markdown_line("") + ), rmd_chunk( name = "pressure", options = list(echo = "FALSE"), code = "plot(pressure)" ), rmd_markdown( - "Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code ", - "that generated the plot." + rmd_markdown_line("Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code "), + rmd_markdown_line("that generated the plot.") ) )