# TODO: added for new tests - to remove when switching the package to edition 3 local_edition(3) test_that("HTML template contains special comment when in shiny prerendered", { skip_if_not_pandoc() special_comment <- "" content <- c("---", "title: shiny", "runtime: shiny_prerendered", "---", "", "```{r}", "1+1", "```") tmp_rmd <- local_rmd_file(content) html <- .render_and_read(tmp_rmd, output_format = "html_document") expect_match(one_string(html), special_comment, fixed = TRUE, label = "hmlt_document template") html <- .render_and_read(tmp_rmd, output_format = "ioslides_presentation") expect_match(one_string(html), special_comment, fixed = TRUE, label = "ioslides_presentation template") html <- .render_and_read(tmp_rmd, output_format = "slidy_presentation") expect_match(one_string(html), special_comment, fixed = TRUE, label = "slidy_presentation template") # no runtime shiny prerendered content <- content[-which(grepl("^runtime", content))] tmp_rmd <- local_rmd_file(content) html <- .render_and_read(tmp_rmd, output_format = "html_document") expect_false(any(grepl(special_comment, html))) }) test_that("Special HEAD comment is added if none in rendered HTML when in shiny prerendered", { skip_if_not_pandoc() # inserted in default template special_comment <- "^\\s*\\s*$" tmp_rmd <- local_rmd_file(c("---", "title: shiny", "runtime: shiny_prerendered", "---", "", "```{r}", "1+1", "```")) html <- shiny_prerendered_html(tmp_rmd, list(quiet = TRUE)) expect_length(grep(special_comment, xfun::split_lines(html)), 1L) # inserted in pandoc template tmp_rmd <- local_rmd_file(c("---", "title: shiny", "runtime: shiny_prerendered", "---", "", "```{r}", "1+1", "```")) opts <- list(template = NULL, mathjax = NULL) html <- shiny_prerendered_html(tmp_rmd, list(output_options = opts, quiet = TRUE)) expect_length(grep(special_comment, xfun::split_lines(html)), 1L) # placed in include headers tmp_rmd <- local_rmd_file(c("---", "title: shiny", "runtime: shiny_prerendered", "---", "", "content")) template <- withr::local_tempfile(fileext = ".html") xfun::write_utf8(c("
", "$header-includes$", "