Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly output vec_fmt_markdown() inside Quarto #1841

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@

* Fixed an issue where `tab_spanner_delim()` would fail to resolve a duplicate id (@olivroy, #1821).


* Fixed an issue with multiple `text_replace()` calls would produce bad result with `cells_column_labels()` (@olivroy, #1824).

* `tidyselect::where()`, `tidyselect::all_of()`, `tidyselect::any_of()` are now re-exported by gt.

* `vec_fmt_markdown()` works correctly inside Quarto again (@olivroy, #1840).

# gt 0.11.0

## New features
Expand Down
8 changes: 6 additions & 2 deletions R/format_vec.R
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,11 @@ vec_fmt_markdown <- function(
if (output == "auto") {
output <- determine_output_format()
}

# Avoid modifying the output to base64enc in Quarto
if (check_quarto() && output == "html") {
rlang::check_installed("withr", "to use vec_fmt_markdown() in Quarto.")
withr::local_envvar(c("QUARTO_BIN_PATH" = ""))
}
vec_fmt_out <-
render_as_vector(
fmt_markdown(
Expand Down Expand Up @@ -3364,7 +3368,7 @@ check_columns_valid_if_strict <- function(
extra_msg = NULL,
call = rlang::caller_env()
) {

# Don't check if strict mode is not enabled
# strict mode is opt-in, not the default
if (!isTRUE(getOption("gt.strict_column_fmt", FALSE))) {
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-quarto.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
skip_on_cran()
test_that("Rendering in Quarto doesn't error with empty string (#1769)", {
local_mocked_bindings(check_quarto = function() TRUE)
withr::local_envvar(c("QUARTO_BIN_PATH" = "path"))
tbl <- mtcars_short %>%
dplyr::select(mpg, cyl) %>% gt()
# note that these don't produce the same output.
Expand All @@ -14,4 +14,8 @@ test_that("Rendering in Quarto doesn't error with empty string (#1769)", {
tbl %>% cols_label(mpg = gt::md("")),
">cyl</th>", fixed = TRUE
)
expect_equal(
vec_fmt_markdown("**x**", output = "html"),
"<strong>x</strong></span>"
)
})
Loading