Skip to content

Commit

Permalink
fix: Quarto detection is different with R > 4.4
Browse files Browse the repository at this point in the history
fix #627
  • Loading branch information
davidgohel committed Apr 29, 2024
1 parent 8e21aaa commit b975e1c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: flextable
Type: Package
Title: Functions for Tabular Reporting
Version: 0.9.6.007
Version: 0.9.6.008
Authors@R: c(
person("David", "Gohel", role = c("aut", "cre"),
email = "[email protected]"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ loops or `if` statements.

- fix issue with `as_image()` when the table contains no text.
- fix font instruction issue with PDF and quarto
- fix issue with Quarto detection and R > 4.4

# flextable 0.9.5

Expand Down
13 changes: 12 additions & 1 deletion R/printers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,18 @@ is_in_bookdown <- function() {
isTRUE(!is_rdocx_document)
}
is_in_quarto <- function() {
isTRUE(knitr::opts_knit$get("quarto.version") > numeric_version("0"))
if (getRversion() >= numeric_version("4.4.0")) {
isTRUE(knitr::opts_knit$get("quarto.version") > 0)
} else {
isTRUE(knitr::opts_knit$get("quarto.version") > numeric_version("0"))
}
}
fake_quarto <- function() {
if (getRversion() >= numeric_version("4.4.0")) {
knitr::opts_knit$set("quarto.version" = 1)
} else {
knitr::opts_knit$set("quarto.version" = numeric_version("1.0"))
}
}
is_in_pkgdown <- function() {
identical(Sys.getenv("IN_PKGDOWN"), "true") &&
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-latex.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test_that("fonts are defined in latex", {
knitr::opts_knit$set("rmarkdown.pandoc.args" = NULL)

# quarto
knitr::opts_knit$set("quarto.version" = numeric_version("1.0"))
flextable:::fake_quarto()
latex_str <- flextable:::gen_raw_latex(ft, quarto = TRUE)
expect_match(latex_str, regexp = "Liberation Sans", fixed = TRUE)
})

0 comments on commit b975e1c

Please sign in to comment.