tests/testthat/test-collections.R

test_that("script and style are not included as `article_content`", {
  skip_on_cran()
  skip_if_not_pandoc()
  rmd <- local_rmd_file(c(
    "---", "title: test", "---",
    "Some content", "",
    "<script> console.log('test')</script>", "",
    "<style>h1 { color: red }</style>", ""
  ))
  html <- local_render(rmd, output_format = 'distill::distill_article')
  expect_identical(str_trim(article_contents(html)), "Some content")
})

Try the distill package in your browser

Any scripts or data that you put into this service are public.

distill documentation built on Oct. 6, 2023, 5:06 p.m.