Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ docs
/doc/
/Meta/
**/.quarto/

/.luarc.json
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: quarto
Title: R Interface to 'Quarto' Markdown Publishing System
Version: 1.5.1.9000
Version: 1.5.1.9002
Authors@R: c(
person("JJ", "Allaire", , "jj@posit.co", role = "aut",
comment = c(ORCID = "0000-0003-0174-9868")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- `.libPaths()` from the calling R session will now be passed by default to all call to quarto as a subprocess. This should solve issue with **pkgdown** or when building vignettes.

- Curly braces in Quarto CLI error messages are now escaped to prevent them from being interpreted as `cli` formatting syntax (#293).

# quarto 1.5.1

- Make sure tests pass on CRAN checks even when Quarto is not installed by adding a gihub action to test when no quarto is available. Also fix tests that were
Expand Down
7 changes: 6 additions & 1 deletion R/quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ quarto_run <- function(
custom_env <- c("current", custom_env)
}

# Special case for tests to force hiding echo
if (is_testing() && getOption("quarto.tests.hide_echo", FALSE)) {
echo <- FALSE
}

res <- withCallingHandlers(
processx::run(
quarto_bin,
Expand Down Expand Up @@ -346,7 +351,7 @@ wrap_quarto_error <- function(cnd, args, .call = rlang::caller_env()) {
msg <- c(
msg,
" " = paste0(rep("-", nchar(msg)), collapse = ""),
quarto_error_msg
cli_escape(quarto_error_msg)
)
}

Expand Down
10 changes: 10 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ warn_or_error <- function(message, ..., .envir = parent.frame()) {
}
}

cli_escape <- function(x) {
x <- gsub("{", "{{", x, fixed = TRUE)
x <- gsub("}", "}}", x, fixed = TRUE)
x
}

# inline knitr:::merge_list()
merge_list <- function(x, y) {
x[names(y)] <- y
Expand Down Expand Up @@ -213,3 +219,7 @@ is_empty_dir <- function(dir) {
files <- list.files(dir, all.files = TRUE, no.. = TRUE)
length(files) == 0
}

is_testing <- function() {
identical(Sys.getenv("TESTTHAT"), "true")
}
3 changes: 3 additions & 0 deletions tests/testthat/resources/cli_error/error.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pandoc = function(doc)
internal_error()
end
7 changes: 7 additions & 0 deletions tests/testthat/resources/cli_error/pdf-error.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
format: latex
filters:
- error.lua
---

content
24 changes: 24 additions & 0 deletions tests/testthat/test-render.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,27 @@ test_that("quarto_render allows to pass output-file meta", {
expect_true(file.exists("final_report.html"))
expect_true(file.exists("final_report.docx"))
})


test_that("{ } are escaped correctly in abort message", {
skip_if_no_quarto()
proj <- test_path("resources", "cli_error")
withr::local_dir(proj)
keep_files <- list.files(".", all.files = TRUE)
withr::defer({
unlink(
setdiff(list.files(".", all.files = TRUE), keep_files),
recursive = TRUE,
force = TRUE
)
})
withr::local_options(quarto.tests.hide_echo = TRUE)
expect_error(
quarto_render(
"pdf-error.qmd",
quiet = FALSE,
quarto_args = c("--log", "test.log")
),
regexp = "Error returned by quarto CLI(.*)nil value \\(global 'internal_error'\\)"
)
})
Loading