blob: 85ad0229c7e352dd6bf4161336338c039843ba2d [file] [log] [blame]
test_that("toc argument works", {
skip_if_not_pandoc()
skip_if_not_installed("xml2")
rmd <- local_temp_draft()
html <- .render_and_read(
rmd,
output_options = list(
toc = TRUE,
pandoc_args = c(pandoc_variable_arg("toc-title", "TOC"))
)
)
toc <- xml2::xml_find_all(html, "//section[@id='TOC']")
expect_length(toc, 1)
expect_equal(
xml2::xml_text(
xml2::xml_find_all(toc, "./nav/*[contains(@id, 'toc-title')]")
),
"TOC"
)
})
test_that("chapter_numbering option controls the numbering script", {
skip_if_not_pandoc()
rmd <- local_temp_rmd_file(
"---",
"title: 'Chapter numbering test'",
"output: revealjs.ids::revealjs_presentation",
"---",
"",
"# One",
"",
"## a",
"",
"# Two"
)
on <- paste(.render_and_read(rmd, xml = FALSE), collapse = "\n")
expect_match(on, "function numberChapters", fixed = TRUE)
expect_match(on, "var start = 1;", fixed = TRUE)
off <- paste(.render_and_read(
rmd,
output_options = list(chapter_numbering = FALSE),
xml = FALSE
), collapse = "\n")
expect_no_match(off, "function numberChapters", fixed = TRUE)
started <- paste(.render_and_read(
rmd,
output_options = list(chapter_numbering = 5),
xml = FALSE
), collapse = "\n")
expect_match(started, "var start = 5;", fixed = TRUE)
expect_error(
.render_and_read(
rmd,
output_options = list(chapter_numbering = "yes"),
xml = FALSE
),
"chapter_numbering"
)
})