-
-
Notifications
You must be signed in to change notification settings - Fork 978
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(beamer): support latex_dependencies (#2558)
- Switch testthat to version 3 officially - Add tests for pdf_document and beamer_presentation
- Loading branch information
Showing
20 changed files
with
83 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
test_that("beamer_presentation() incorporates latex dependencies", { | ||
expected_dependencies <- c( | ||
"\\usepackage{longtable}", # from extra_dependencies | ||
"\\usepackage{hyperref}" # from knit_meta | ||
) | ||
|
||
extra_dependencies <- list( | ||
# do not include non-latex dependencies | ||
# as pre processor does not care the kind of extra dependencies | ||
latex_dependency("longtable") | ||
) | ||
knit_meta <- list( | ||
latex_dependency("hyperref"), | ||
html_dependency_jquery() # pre_processor should remove html dependencies | ||
) | ||
|
||
fmt <- beamer_presentation(extra_dependencies = extra_dependencies) | ||
|
||
pandoc_args <- fmt$pre_processor( | ||
list(), | ||
tempfile(), | ||
"static", | ||
knit_meta, | ||
tempdir(), | ||
tempdir() | ||
) | ||
|
||
included <- pandoc_args[which(pandoc_args == "--include-in-header") + 1L] | ||
expect_length(included, 1L) | ||
expect_true(file.exists(included)) | ||
expect_identical(readLines(included), expected_dependencies) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
# TODO: to remove when switching the package to edition 3 | ||
local_edition(3) | ||
|
||
test_that("Only mathjax is supported", { | ||
expect_error(ioslides_presentation(math_method = "katex")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
test_that("pdf_document() incorporates latex dependencies", { | ||
expected_dependencies <- c( | ||
"\\usepackage{longtable}", # from extra_dependencies | ||
"\\usepackage{hyperref}" # from knit_meta | ||
) | ||
|
||
extra_dependencies <- list( | ||
# do not include non-latex dependencies | ||
# as pre processor does not care the kind of extra dependencies | ||
latex_dependency("longtable") | ||
) | ||
knit_meta <- list( | ||
latex_dependency("hyperref"), | ||
html_dependency_jquery() # pre_processor should remove html dependencies | ||
) | ||
|
||
fmt <- pdf_document(extra_dependencies = extra_dependencies) | ||
|
||
pandoc_args <- fmt$pre_processor( | ||
list(), | ||
tempfile(), | ||
"static", | ||
knit_meta, | ||
tempdir(), | ||
tempdir() | ||
) | ||
|
||
included <- pandoc_args[which(pandoc_args == "--include-in-header") + 1L] | ||
expect_length(included, 1L) | ||
expect_true(file.exists(included)) | ||
expect_identical(readLines(included), expected_dependencies) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters