Skip to content

Commit

Permalink
Disable anchor sections for learnr tutorials (#447)
Browse files Browse the repository at this point in the history
Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
  • Loading branch information
gadenbuie committed Nov 23, 2020
1 parent dfe7401 commit 7eb2b29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/tutorial-format.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ tutorial <- function(fig_width = 6.5,
pandoc_args = NULL,
...) {

if ("anchor_sections" %in% names(list(...))) {
stop("learnr tutorials do not support the `anchor_sections` option.")
}

# base pandoc options
args <- c()

Expand Down Expand Up @@ -137,6 +141,7 @@ tutorial <- function(fig_width = 6.5,
template = "default",
extra_dependencies = extra_dependencies,
bootstrap_compatible = TRUE,
anchor_sections = FALSE,
...
)

Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-tutorial-format.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("tutorial() returns an rmarkdown format", {
expect_true(inherits(tutorial(), "rmarkdown_output_format"))
})

test_that("tutorial() does not support anchor_sections", {
expect_error(tutorial(anchor_sections = TRUE), "do not support")
expect_error(tutorial(anchor_sections = FALSE), "do not support")
})

0 comments on commit 7eb2b29

Please sign in to comment.