Skip to content

Commit 26a8583

Browse files
committed
output_file now map to output-file Quarto meta and not the cli flag
```` quarto_render("test.qmd", quarto_args = c("--output", "test.html")) ```` Can restore the previous behavior by setting the command line flag
1 parent d3c732c commit 26a8583

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: quarto
22
Title: R Interface to 'Quarto' Markdown Publishing System
3-
Version: 1.4.4.9017
3+
Version: 1.4.4.9018
44
Authors@R: c(
55
person("JJ", "Allaire", , "[email protected]", role = "aut",
66
comment = c(ORCID = "0000-0003-0174-9868")),

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# quarto (development version)
22

3+
- `quarto_render(output_file = )` now sets the `output-file` Quarto metadata instead of the `--output` CLI flag. This allows the output file information to correctly be processed by Quarto, as if passed in a YAML header. e.g. it allows to support multiple output formats in the same render call. `quarto_render(quarto_args = c('--output', 'dummy.html'))` can still be used to set the `--output` CLI flag to enforce using the CLI flag and not the metadata processed by Quarto (#251, #43).
4+
35
- Added `check_newer_version()` function to check if a newer version of Quarto is available. The function compares the current Quarto version against the latest stable and prerelease versions. It is aimed for verbosity by default (`verbose = TRUE`), but `verbose = FALSE` can also be set for just checking update availability with TRUE or FALSE return values. Version information is cached per session for up to 24 hours to minimize network requests.
46

57
- Added `write_yaml_metadata_block()` function to dynamically set YAML metadata in Quarto documents from R code chunks. This addresses the limitation where Quarto metadata must be static and defined in the document header. The function enables conditional content and metadata-driven document behavior based on R computations (thanks, @kmasiello, #137, #160).

R/render.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,11 @@ quarto_render <- function(
154154
if (!missing(output_format)) {
155155
args <- c(args, "--to", paste(output_format, collapse = ","))
156156
}
157-
if (!missing(output_file)) {
158-
args <- c(args, "--output", output_file)
157+
if (!is.null(output_file)) {
158+
# handle problem with cli flag
159+
# https://github.com/quarto-dev/quarto-cli/issues/8399
160+
# args <- c(args, "--output", output_file)
161+
metadata[['output-file']] <- output_file
159162
}
160163
if (!missing(execute)) {
161164
args <- c(args, ifelse(isTRUE(execute), "--execute", "--no-execute"))
@@ -187,7 +190,7 @@ quarto_render <- function(
187190
args <- c(args, "--cache-refresh")
188191
}
189192
# metadata to pass to quarto render
190-
if (!missing(metadata)) {
193+
if (!is.null(metadata)) {
191194
# We merge meta if there is metadata_file passed
192195
if (!missing(metadata_file)) {
193196
metadata <- merge_list(

tests/testthat/test-render.R

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,26 @@ test_that("`quarto_render(as_job = TRUE)` is wrapable", {
9999
Sys.sleep(10)
100100
expect_true(file.exists(output))
101101
})
102+
103+
test_that("quarto_render allows to pass output-file meta", {
104+
skip_if_no_quarto()
105+
qmd <- local_qmd_file(c(
106+
"---",
107+
"title: Example title",
108+
"format:",
109+
" html:",
110+
" toc: true",
111+
" docx:",
112+
" toc: true",
113+
"---",
114+
""
115+
))
116+
out <- quarto_render(
117+
qmd,
118+
output_file = "final_report",
119+
output_format = "all",
120+
quiet = TRUE
121+
)
122+
expect_true(file.exists("final_report.html"))
123+
expect_true(file.exists("final_report.docx"))
124+
})

0 commit comments

Comments
 (0)