Skip to content

Commit

Permalink
Issue #86: Better knitr output detection
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jan 26, 2024
1 parent 085f458 commit 5397dc9
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions R/sanity.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ sanitize_output <- function(output) {
out <- output
}

if (isTRUE(check_dependency("knitr")) && isTRUE(check_dependency("rmarkdown"))) {
if (isTRUE(check_dependency("knitr"))) {

if (isTRUE(knitr::is_latex_output())) {
if (isTRUE(knitr::pandoc_to() == "latex")) {
usepackage_latex("codehigh")
usepackage_latex("float")
usepackage_latex("tabularray", extra_lines = c(
Expand All @@ -31,8 +31,20 @@ sanitize_output <- function(output) {
)
if (is.null(output)) out <- "latex"

} else if (isTRUE(knitr::is_html_output())) {
} else if (isTRUE(knitr::pandoc_to() == "html")) {
if (is.null(output)) out <- "html"

} else if (isTRUE(knitr::pandoc_to() == "typst")) {
if (is.null(output)) out <- "typst"

} else if (isTRUE(knitr::pandoc_to() == "docx")) {
if (is.null(output)) out <- "markdown"

} else if (isTRUE(knitr::pandoc_to() == "commonmark")) {
if (is.null(output)) out <- "markdown"

} else {
if (is.null(output)) out <- "markdown"
}

}
Expand Down

0 comments on commit 5397dc9

Please sign in to comment.