diff --git a/DESCRIPTION b/DESCRIPTION index 3ddd081..c5d2d6c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: quarto Title: R Interface to 'Quarto' Markdown Publishing System -Version: 1.3.6 +Version: 1.3.7 Authors@R: c( person("JJ", "Allaire", , "jj@rstudio.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0174-9868")), diff --git a/NEWS.md b/NEWS.md index 524facb..0b73f4f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # quarto (development version) +- Add `quarto_args` to `quarto_render()` and other commands to pass additional arguments to `quarto` CLI commands. This is for advanced usage e.g. when new options are added to Quarto CLI that would not be user-facing in this package's functions (thanks, @gadenbuie, #125). + - Add `quiet` argument to pass `--quiet` to `quarto` CLI commands - Error message now advises to re-run with `quiet = FALSE` because `quarto_render(quiet = TRUE)` will run `quarto render` in quiet mode (thanks to @gadenbuie, #126, @wlandau, #16). diff --git a/R/add.R b/R/add.R index c4b57d2..f17e466 100644 --- a/R/add.R +++ b/R/add.R @@ -19,8 +19,6 @@ #' #' @param no_prompt Do not prompt to confirm approval to download external extension. #' -#' @param quarto_args Character vector of other `quarto` CLI flag pass to the command. -#' #' @examples #' \dontrun{ #' # Install a template and set up a draft document from a GitHub repository diff --git a/R/inspect.R b/R/inspect.R index b103f26..2d1da62 100644 --- a/R/inspect.R +++ b/R/inspect.R @@ -5,7 +5,7 @@ #' and dependent resources. #' #' @inheritParams quarto_render -#' @inheritParams quarto_add_extension +#' #' @param input The input file or project directory to inspect. #' #' @return Named list. For input files, the list contains the elements diff --git a/R/render.R b/R/render.R index c059031..3282886 100644 --- a/R/render.R +++ b/R/render.R @@ -41,6 +41,9 @@ #' @param profile [Quarto project #' profile(s)](https://quarto.org/docs/projects/profiles.html) to use. Either #' a character vector of profile names or `NULL` to use the default profile. +#' @param quarto_args Character vector of other `quarto` CLI flag pass to the +#' command. This is mainly for advanced usage, e.g it can be useful for new +#' options added to quarto CLI and not yet supported as function argument. #' @param pandoc_args Additional command line options to pass to pandoc. #' @param as_job Render as an RStudio background job. Default is "auto", #' which will render individual documents normally and projects as @@ -82,6 +85,7 @@ quarto_render <- function(input = NULL, debug = FALSE, quiet = FALSE, profile = NULL, + quarto_args = NULL, pandoc_args = NULL, as_job = getOption("quarto.render_as_job", "auto")) { @@ -176,6 +180,9 @@ quarto_render <- function(input = NULL, if (!is.null(profile)) { args <- cli_arg_profile(profile, args) } + if (!is.null(quarto_args)) { + args <- c(args, quarto_args) + } if (!is.null(pandoc_args)) { args <- c(args, pandoc_args) } diff --git a/R/use.R b/R/use.R index a672773..8083987 100644 --- a/R/use.R +++ b/R/use.R @@ -2,6 +2,7 @@ #' #' Install and use a template for Quarto using `quarto use`. #' +#' @inheritParams quarto_render #' @inheritParams quarto_add_extension #' #' @param template The template to install, either an archive or a GitHub diff --git a/man/quarto_add_extension.Rd b/man/quarto_add_extension.Rd index 7404e90..8232005 100644 --- a/man/quarto_add_extension.Rd +++ b/man/quarto_add_extension.Rd @@ -20,7 +20,9 @@ repository as described in the documentation \item{quiet}{Suppress warning and other messages.} -\item{quarto_args}{Character vector of other \code{quarto} CLI flag pass to the command.} +\item{quarto_args}{Character vector of other \code{quarto} CLI flag pass to the +command. This is mainly for advanced usage, e.g it can be useful for new +options added to quarto CLI and not yet supported as function argument.} } \description{ Add an extension to this folder or project by running \verb{quarto add} diff --git a/man/quarto_inspect.Rd b/man/quarto_inspect.Rd index 481aba1..9134ed9 100644 --- a/man/quarto_inspect.Rd +++ b/man/quarto_inspect.Rd @@ -14,7 +14,9 @@ a character vector of profile names or \code{NULL} to use the default profile.} \item{quiet}{Suppress warning and other messages.} -\item{quarto_args}{Character vector of other \code{quarto} CLI flag pass to the command.} +\item{quarto_args}{Character vector of other \code{quarto} CLI flag pass to the +command. This is mainly for advanced usage, e.g it can be useful for new +options added to quarto CLI and not yet supported as function argument.} } \value{ Named list. For input files, the list contains the elements diff --git a/man/quarto_render.Rd b/man/quarto_render.Rd index ce619e8..0c14a51 100644 --- a/man/quarto_render.Rd +++ b/man/quarto_render.Rd @@ -22,6 +22,7 @@ quarto_render( debug = FALSE, quiet = FALSE, profile = NULL, + quarto_args = NULL, pandoc_args = NULL, as_job = getOption("quarto.render_as_job", "auto") ) @@ -80,6 +81,10 @@ specified, with low precedence on \code{metadata} options.} \item{profile}{\href{https://quarto.org/docs/projects/profiles.html}{Quarto project profile(s)} to use. Either a character vector of profile names or \code{NULL} to use the default profile.} +\item{quarto_args}{Character vector of other \code{quarto} CLI flag pass to the +command. This is mainly for advanced usage, e.g it can be useful for new +options added to quarto CLI and not yet supported as function argument.} + \item{pandoc_args}{Additional command line options to pass to pandoc.} \item{as_job}{Render as an RStudio background job. Default is "auto", diff --git a/man/quarto_use_template.Rd b/man/quarto_use_template.Rd index 1153c38..d677416 100644 --- a/man/quarto_use_template.Rd +++ b/man/quarto_use_template.Rd @@ -13,7 +13,9 @@ repository as described in the documentation \item{no_prompt}{Do not prompt to confirm approval to download external extension.} -\item{quarto_args}{Character vector of other \code{quarto} CLI flag pass to the command.} +\item{quarto_args}{Character vector of other \code{quarto} CLI flag pass to the +command. This is mainly for advanced usage, e.g it can be useful for new +options added to quarto CLI and not yet supported as function argument.} } \description{ Install and use a template for Quarto using \verb{quarto use}. diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index 30ad2b6..dfac35c 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -57,7 +57,15 @@ expect_snapshot_qmd_output <- function(name, input, output_file = NULL, ...) { } -transform_quarto_cli_in_output <- function(lines) { - # it will be quarto.exe only on windows - gsub("quarto\\.(exe|cmd)", "quarto", lines) +transform_quarto_cli_in_output <- function(full_path = FALSE) { + return( + function(lines) { + if (full_path) { + gsub(find_quarto(), "", lines, fixed = TRUE) + } else { + # it will be quarto.exe only on windows + gsub("quarto\\.(exe|cmd)", "quarto", lines) + } + } + ) } diff --git a/tests/testthat/test-quarto.R b/tests/testthat/test-quarto.R index 45b8e9b..b374462 100644 --- a/tests/testthat/test-quarto.R +++ b/tests/testthat/test-quarto.R @@ -8,6 +8,6 @@ test_that("quarto_run gives guidance in error", { expect_snapshot( error = TRUE, quarto_run(c("rend", "--quiet")), - transform = transform_quarto_cli_in_output + transform = transform_quarto_cli_in_output() ) }) diff --git a/tests/testthat/test-render.R b/tests/testthat/test-render.R index 0b5b94a..d37b535 100644 --- a/tests/testthat/test-render.R +++ b/tests/testthat/test-render.R @@ -45,3 +45,16 @@ test_that("metadata-file and metadata are merged in quarto_render", { metadata_file = yaml, metadata = list(title = "test2") ) }) + +test_that("quarto_args in quarto_render", { + skip_if_no_quarto() + qmd <- local_qmd_file(c("content")) + withr::local_options(quarto.echo_cmd = TRUE) + withr::local_dir(dirname(qmd)) + file.rename(basename(qmd), "input.qmd") + # metadata + expect_snapshot( + quarto_render("input.qmd", quiet = TRUE, quarto_args = c("--to", "native")), + transform = transform_quarto_cli_in_output(full_path = TRUE) + ) +})