| Title: | R Interface to 'Quarto' Markdown Publishing System |
| Version: | 1.5.1 |
| Description: | Convert R Markdown documents and 'Jupyter' notebooks to a variety of output formats using 'Quarto'. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/quarto-dev/quarto-r,https://quarto-dev.github.io/quarto-r/ |
| BugReports: | https://github.com/quarto-dev/quarto-r/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | cli, fs, htmltools, jsonlite, later, lifecycle, processx,rlang, rmarkdown, rstudioapi, tools, utils, xfun, yaml (≥2.3.10) |
| Suggests: | bslib, callr, curl, dplyr, flextable, ggiraph, ggplot2, gt,heatmaply, kableExtra, knitr, palmerpenguins, patchwork,pkgload, plotly, rsconnect (≥ 0.8.26), testthat (≥ 3.1.7),thematic, tidyverse, tinytable, whoami, withr |
| VignetteBuilder: | quarto |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| SystemRequirements: | Quarto command line tool(<https://github.com/quarto-dev/quarto-cli>). |
| NeedsCompilation: | no |
| Packaged: | 2025-09-04 13:45:05 UTC; chris |
| Author: | JJ Allaire |
| Maintainer: | Christophe Dervieux <cderv@posit.co> |
| Repository: | CRAN |
| Date/Publication: | 2025-09-04 15:30:02 UTC |
quarto: R Interface to 'Quarto' Markdown Publishing System
Description

Convert R Markdown documents and 'Jupyter' notebooks to a variety of output formats using 'Quarto'.
Author(s)
Maintainer: Christophe Dervieuxcderv@posit.co (ORCID)
Authors:
JJ Allairejj@posit.co (ORCID)
Other contributors:
Posit Software, PBC [copyright holder, funder]
Gordon Woodhull [contributor]
See Also
Useful links:
Report bugs athttps://github.com/quarto-dev/quarto-r/issues
Add spin preamble to R script
Description
Adds a minimal spin preamble to an R script file if one doesn't already exist.The preamble includes a title derived from the filename and is formatted asa YAML block suitable preprended with#' forknitr::spin().
Usage
add_spin_preamble(script, title = NULL, preamble = NULL, quiet = FALSE)Arguments
script | Path to the R script file |
title | Custom title for the preamble. If provided, overrides any titlein the |
preamble | Named list of YAML metadata to include in preamble.The |
quiet | If |
Details
This is useful to prepare R scripts for use withQuarto Script rendering support.Seehttps://quarto.org/docs/computations/render-scripts.html#knitr
Value
Invisibly returns the script path if modified, otherwise invisible NULL
Preamble format
For a script namedanalysis.R, the function adds this preamble by default:
#' ---#' title: analysis#' ---#'# Original script content starts here
This is the minimal preamble required for Quarto Script rendering, so thatEngine Bindings works.
Examples
## Not run: # Basic usage with default titleadd_spin_preamble("analysis.R")# Custom titleadd_spin_preamble("analysis.R", title = "My Analysis")# Custom preamble with multiple fieldsadd_spin_preamble("analysis.R", preamble = list( title = "Advanced Analysis", author = "John Doe", date = Sys.Date(), format = "html"))# Title parameter overrides preamble titleadd_spin_preamble("analysis.R", title = "Final Title", # This takes precedence preamble = list( title = "Ignored Title", author = "John Doe" ))## End(Not run)Check for newer version of Quarto
Description
Checks if a newer version of Quarto is available and informs the user abouttheir current version status. The function compares the current Quarto versionagainst the latest stable and prerelease versions available online.
Usage
check_newer_version(version = quarto_version(), verbose = TRUE)Arguments
version | Character string specifying the Quarto version to check.Defaults to the currently installed version detected by |
verbose | Logical indicating whether to print informational messages.Defaults to |
Details
The function handles three scenarios:
Development version (99.9.9): Skips version check with informational message
Prerelease version: Compares against latest prerelease and informs about updates
Stable version: Compares against latest stable version and suggests updates if needed
Version information is fetched from Quarto's download JSON endpoints and cached in current sessionfor up to 24 hours to avoid repeated network requests.
Value
Invisibly returns a logical value:
TRUEif an update is availableFALSEif no update is needed or when using development versionThe function is primarily called for its side effects of printinginformational messages (whenverbose = TRUE).
Network Requirements
This function requires an internet connection to fetch the latest versioninformation from quarto.org. If the network request fails, an error will be thrown.
See Also
quarto_version() for getting the current Quarto version,
Examples
# Check current Quarto versioncheck_newer_version()# Check a specific versioncheck_newer_version("1.7.30")# Check development version (will skip check)check_newer_version("99.9.9")# Check silently without messagesresult <- check_newer_version(verbose = FALSE)if (result) { message("Update available!")}Detect Bookdown Cross-References for Quarto Migration
Description
Scans R Markdown or Quarto files to identify bookdown cross-references thatneed to be converted to Quarto syntax. Provides detailed reports and guidancefor migrating from bookdown to Quarto.
Usage
detect_bookdown_crossrefs(path = ".", verbose = FALSE)Arguments
path | Character string. Path to a single Typically used for Bookdown projects or R Markdown documents usingbookdown output formats (e.g., |
verbose | Logical. If |
Details
This function helps users migrate from bookdown to Quarto by detectingcross-references that use bookdown syntax and need manual conversion.
Detected Cross-Reference Types
Auto-detectable conversions:
Figures:
\@ref(fig:label)->@fig-labelTables:
\@ref(tab:label)->@tbl-labelEquations:
\@ref(eq:label)->@eq-labelSections:
\@ref(label)->@sec-labelTheorems:
\@ref(thm:label)->@thm-label(also lem, cor, prp, def, exm, exr)
Manual conversion required:
Numbered equations:
(\#eq:label)-> requires equation restructuringTheorem blocks: Need explicit Quarto div syntax conversionAll three formats from several bookdown versions are supported:
Old syntax with label:
{theorem, label="thm:label"}Old syntax without label:
{theorem chunk_name}New div syntax:
::: {.theorem #thm-label}
Section headers: Need explicit
{#sec-label}IDsFigure labels: Need explicit
#| label: fig-labelin code chunksTable labels: Need explicit
#| label: tbl-labelin code chunks
Unsupported in Quarto:
Conjecture (
cnj) and Hypothesis (hyp) references
Adaptive Guidance
The function providescontext-aware warnings that only show syntax patternsactually found in your files. For example, if your project only uses the oldtheorem syntax without labels, you'll only see guidance for that specific pattern,not all possible variations.
Output Modes
Default (verbose = FALSE):
Compact file-by-file summary
Cross-reference counts by type
Manual conversion requirements summary
Verbose (verbose = TRUE):
Detailed line-by-line breakdown
Exact bookdown -> Quarto syntax transformations
Context-aware conversion guidance showing only relevant syntax patterns
Comprehensive examples with documentation links
Value
Invisibly returns a list of detected cross-references with theirfile locations, line numbers, and conversion details. ReturnsNULL ifno cross-references are found.
See Also
Bookdown documentation:
Quarto documentation:
Examples
## Not run: # Scan current directory (compact output)detect_bookdown_crossrefs()# Scan specific file with detailed outputdetect_bookdown_crossrefs("my-document.Rmd", verbose = TRUE)# Scan directory with context-aware guidancedetect_bookdown_crossrefs("path/to/bookdown/project", verbose = TRUE)## End(Not run)Find the root of a Quarto project
Description
This function checks if the current working directory is within a Quartoproject by looking for Quarto project files (_quarto.yml or_quarto.yaml).Unlikeget_running_project_root(), this works both during rendering andinteractive sessions.
Usage
find_project_root(path = ".")Arguments
path | Character. Path to check for Quarto project files. Defaults tocurrent working directory. |
Value
Character Path of the project root directory if found, orNULL
See Also
get_running_project_root() for detecting active Quarto rendering
Examples
tmpdir <- tempfile()dir.create(tmpdir)find_project_root(tmpdir)quarto_create_project("test-proj", type = "blog", dir = tmpdir, no_prompt = TRUE, quiet = TRUE)blog_post_dir <- file.path(tmpdir, "test-proj", "posts", "welcome")find_project_root(blog_post_dir)xfun::in_dir(blog_post_dir, { # Check if current directory is a Quarto project or in one !is.null(find_project_root())})# clean upunlink(tmpdir, recursive = TRUE)Get the root of the currently running Quarto project
Description
This function is to be used inside cells and will return the project rootwhen doingquarto_render() by detecting Quarto project environment variables.
Usage
get_running_project_root()Details
Quarto setsQUARTO_PROJECT_ROOT andQUARTO_PROJECT_DIR environmentvariables when executing commands within a Quarto project context (e.g.,quarto render,quarto preview). This function detects their presence.
Note that this function will returnNULL when running code interactivelyin an IDE (even within a Quarto project directory), as these specificenvironment variables are only set during Quarto command execution.
Value
Character Quarto project root path from set environment variables.
Use in Quarto document cells
This function is particularly useful in Quarto document cells where you want toget the project root path dynamically during rendering. Cell example:
```{r}`r ''` # Get the project root path project_root <- get_running_project_root()```See Also
find_project_root()for finding the Quarto project root directoryproject_path()for constructing paths relative to the project root
Examples
## Not run: get_running_project_root()## End(Not run)Check if a Quarto document uses parameters
Description
Determines whether a Quarto document uses parameters by examining the documentstructure and metadata. This function works with both knitr and Jupyter engines,using different detection methods for each:
Usage
has_parameters(input)Arguments
input | Path to the Quarto document (.qmd or .ipynb file) to inspect. |
Details
Knitr engine (.qmd files): Checks for a "params" field in the document'sYAML metadata using
quarto_inspect()Jupyter engine (.ipynb files): Looks for code cells tagged with "parameters"following the papermill convention. For .ipynb files, the function parses thenotebook JSON directly due to limitations in
quarto inspect.
Parameters in Quarto enable creating dynamic, reusable documents. This functionhelps identify parameterized documents programmatically, which is useful for:
Document processing workflows
Automated report generation
Parameter validation before rendering
Project analysis and organization
For more information about using parameters in Quarto, seehttps://quarto.org/docs/computations/parameters.html
Value
Logical.TRUE if the document uses parameters,FALSE otherwise.
Examples
## Not run: # Check if a document uses parametershas_parameters("my-document.qmd")# Check a parameterized reporthas_parameters("parameterized-report.qmd")# Check a Jupyter notebookhas_parameters("analysis.ipynb")# Use in a workflowif (has_parameters("report.qmd")) { message("This document accepts parameters")}## End(Not run)Check is a directory is using quarto
Description
This function will check if a directory is using quarto by looking for
_quarto.ymlat its rootat least one
.qmdfile in the directory
Usage
is_using_quarto(dir = ".", verbose = FALSE)Arguments
dir | The directory to check |
verbose | print message about the result of the check |
Examples
dir.create(tmpdir <- tempfile())is_using_quarto(tmpdir)file.create(file.path(tmpdir, "_quarto.yml"))is_using_quarto(tmpdir)unlink(tmpdir, recursive = TRUE)Create a new blog post
Description
Creates (and potentially opens) theindex.qmd file for a new blog post.
Usage
new_blog_post( title, dest = NULL, wd = NULL, open = rlang::is_interactive(), call = rlang::current_env(), ...)Arguments
title | A character string for the title of the post. It is convertedto title case via |
dest | A character string (or NULL) for the path within |
wd | An optional working directory. If |
open | A logical: have the default editor open a window to edit the |
call | The execution environment of a currentlyrunning function, e.g. |
... | A named list of values to be added to the yaml header, such as |
Value
The path to the index file.
Examples
## Not run: \donttest{new_blog_post("making quarto blog posts", categories = c("R"))}## End(Not run)Get path relative to project root (Quarto-aware)
Description
This function constructs file paths relative to the project root whenrunning in a Quarto context (usingQUARTO_PROJECT_ROOT orQUARTO_PROJECT_DIRenvironment variables), or falls back to intelligent project root detectionwhen not in a Quarto context.
It is experimental and subject to change in future releases. The automaticproject root detection may not work reliably in all contexts, especially whenprojects have complex directory structures or when running in non-standardenvironments. For a more explicit and potentially more robust approach,consider usinghere::i_am() to declare your project structure,followed byhere::here() for path construction. See examples for comparison.
Usage
project_path(..., root = NULL)Arguments
... | Character vectors of path components to be joined |
root | Project root directory. If |
Details
The function uses the following fallback hierarchy to determine the project root:
Quarto environment variables set during Quarto commands (e.g.,
quarto render):QUARTO_PROJECT_ROOTenvironment variable (set by Quarto commands)QUARTO_PROJECT_DIRenvironment variable (alternative Quarto variable)
Fallback to intelligent project root detection using
xfun::proj_root()for interactive sessions:_quarto.ymlor_quarto.yaml(Quarto project files)DESCRIPTIONfile withPackage:field (R package or Project).Rprojfiles withVersion:field (RStudio projects)
Last fallback is the current working directory if no project root can be determined.A warning is issued to alert users that behavior may differ between interactive use and Quarto rendering,as in this case the computed path may be wrong.
Value
A character vector of the normalized file path relative to the project root.
Use in Quarto document cells
This function is particularly useful in Quarto document cells where you want touse a path relative to the project root dynamically during rendering.
```{r}`r ''` # Get a csv path from data directory in the Quarto project root data <- project_path("data", "my_data.csv")```See Also
here::here()andhere::i_am()for a similar function that works with R projectsfind_project_root()to search for Quarto Project configuration in parents directoriesget_running_project_root()for detecting the project root in Quarto commandsxfun::from_root()for the underlying path constructionxfun::proj_root()for project root detection logic
Examples
## Not run: # Create a dummy Quarto project structure for exampletmpdir <- tempfile("quarto_project")dir.create(tmpdir)quarto::quarto_create_project( 'test project', type = 'blog', dir = tmpdir, no_prompt = TRUE, quiet = TRUE)project_dir <- file.path(tmpdir, "test project")# Simulate working within a blog postxfun::in_dir( dir = file.path(project_dir, "posts", "welcome"), { # Reference a data file from project root # ../../data/my_data.csv quarto::project_path("data", "my_data.csv") # Reference a script from project root # ../../R/analysis.R quarto::project_path("R", "analysis.R") # Explicitly specify root (overrides automatic detection) # ../../data/file.csv quarto::project_path("data", "file.csv", root = "../..") # Alternative approach using here::i_am() (potentially more robust) # This approach requires you to declare where you are in the project: if (requireNamespace("here", quietly = TRUE)) { # Declare that this document is in the project root or subdirectory here::i_am("posts/welcome/index.qmd") # Now here::here() will work reliably from the project root here::here("data", "my_data.csv") here::here("R", "analysis.R") }})## End(Not run)Convert Quarto document to R script
Description
Extracts R code cells from a Quarto document and writes them to an R scriptfile that can be rendered with the same options. The Markdown text is notpreserved, but R chunk options are kept as comment headers using Quarto's#| syntax.
This function is still experimental and may slightly change infuture releases, depending on feedback.
Usage
qmd_to_r_script(qmd, script = NULL)Arguments
qmd | Character. Path to the input Quarto document (.qmd file). |
script | Character. Path to the output R script file. If |
Details
This function processes a Quarto document by:
Extracting only R code cells (markdown and cell in other languages are ignored)
Preserving chunk options as
#|comment headersAdding the document's YAML metadata as a spin-style header
Creating an R script that can be rendered with the same options
Chunk option handling:
Chunks with
purl: falseare completely skipped and not included in the outputChunks with
eval: falsehave their code commented out (prefixed with# ) in the R scriptAll other chunk options are preserved as
#|comment headers
File handling:
If the output R script already exists, the function will abort with an error
Non-R code cells (e.g., Python, Julia, Observable JS) are ignored
If no R code cells are found, the function does nothing and returns
NULL
Compatibility:
The resulting R script is compatible with Quarto's script rendering viaknitr::spin() and can be rendered directly withquarto render script.R.Seehttps://quarto.org/docs/computations/render-scripts.html#knitr formore details on rendering R scripts with Quarto.
The resulting R script uses Quarto's executable cell format with#|comments to preserve chunk options likelabel,echo,output, etc.
The resulting R script could also besource()d in R, as anyeval = FALSE will be commented out.
Limitations:
This function relies on static analysis of the Quarto document byquarto inspect. This means thatanyknitr specific options likechild= or specific feature likeknitr::read_chunk() are not supported.They rely on tangling or knitting byknitr itself. For this support,one should look atknitr::hook_purl() orknitr::purl().
Value
Invisibly returns the path to the created R script file, orNULL if no R code cells were found.
Examples
## Not run: # Convert a Quarto document to R scriptqmd_to_r_script("my-document.qmd")# Creates "my-document.R"# Specify custom output fileqmd_to_r_script("my-document.qmd", script = "extracted-code.R")## End(Not run)Install a Quarto extensions
Description
Add an extension to this folder or project by runningquarto add
Usage
quarto_add_extension( extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL)Arguments
extension | The extension to install, either an archive or a GitHubrepository as described in the documentationhttps://quarto.org/docs/extensions/managing.html. |
no_prompt | Do not prompt to confirm approval to download external extension. |
quiet | Suppress warning and other messages, from R and also Quarto CLI(i.e
On Github Actions, it will always be |
quarto_args | Character vector of other |
Extension Trust
Quarto extensions may execute code when documents are rendered. Therefore, ifyou do not trust the author of an extension, we recommend that you do notinstall or use the extension.By defaultno_prompt = FALSE which means thatthe function will ask for explicit approval when used interactively, ordisallow installation.
Examples
## Not run: # Install a template and set up a draft document from a GitHub repositoryquarto_add_extension("quarto-ext/fontawesome")# Install a template and set up a draft document from a ZIP archivequarto_add_extension("https://github.com/quarto-ext/fontawesome/archive/refs/heads/main.zip")## End(Not run)Check if quarto is available and version meet some requirements
Description
This function allows to test if Quarto is available and meets version requirement, a min, max orin between requirement.
Usage
quarto_available(min = NULL, max = NULL, error = FALSE)Arguments
min | Minimum version expected. |
max | Maximum version expected |
error | If |
Details
Ifmin andmax are provided, this will check if Quarto version isin-between two versions. If non is provided (keeping the defaultNULL forboth), it will just check for Quarto availability version and returnFALSE if not found.
Value
logical.TRUE if requirement is met,FALSE otherwise.
Examples
# Is there an active version available ?quarto_available()# check for a minimum requirementquarto_available(min = "1.5")# check for a maximum versionquarto_available(max = "1.6")# only returns TRUE if Pandoc version is between two boundsquarto_available(min = "1.4", max = "1.6")Check configurations for quarto binary used
Description
This function check the configuration for the quarto package R package todetect a possible difference with version used by RStudio IDE.
Usage
quarto_binary_sitrep(verbose = TRUE, debug = FALSE)Arguments
verbose | if |
debug | if |
Value
TRUE if this package should be using the same quarto binary as theRStudio IDE.FALSE otherwise if a difference is detected or quarto is notfound. Useverbose = TRUE ordebug = TRUE to get detailed information.
Examples
quarto_binary_sitrep(verbose = FALSE)quarto_binary_sitrep(verbose = TRUE)quarto_binary_sitrep(debug = TRUE)Create a quarto project
Description
This function callsquarto create project <type> <name>. It creates a newdirectory with the project name, inside the requested parent directory, andadds some starter files that are appropriate to the project type.
Usage
quarto_create_project( name, type = "default", dir = ".", title = name, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL)Arguments
name | The name of the project and the directory that will be created. Special caseis to use |
type | The type of project to create. As of Quarto 1.4, it can be one of |
dir | The directory in which to create the new Quarto project, i.e. theparent directory. |
title | The title of the project. By default, it will be the name of the project, same as directory name created.or "My project" if |
no_prompt | Do not prompt to approve the creation of the new projectfolder. |
quiet | Suppress warning and other messages, from R and also Quarto CLI(i.e
On Github Actions, it will always be |
quarto_args | Character vector of other |
Quarto version required
This function requires Quarto 1.4 or higher. Usequarto_version() to seeyour current Quarto version.
See Also
Quarto documentation onQuarto projects
Examples
## Not run: # Create a new project directory in another directoryquarto_create_project("my-first-quarto-project", dir = "~/tmp")# Create a new project directory in the current directoryquarto_create_project("my-first-quarto-project")# Create a new project with a different titlequarto_create_project("my-first-quarto-project", title = "My Quarto Project")# Create a new project inside the current directory directlyquarto_create_project(".", title = "My Quarto Project")## End(Not run)Inspect Quarto Input File or Project
Description
Inspect a Quarto project or input path. Inspecting a project returns itsconfig and engines. Inspecting an input path return its formats, engine,and dependent resources.
Usage
quarto_inspect(input = ".", profile = NULL, quiet = FALSE, quarto_args = NULL)Arguments
input | The input file or project directory to inspect. |
profile | Quarto project profile(s) to use. Eithera character vector of profile names or |
quiet | Suppress warning and other messages, from R and also Quarto CLI(i.e
On Github Actions, it will always be |
quarto_args | Character vector of other |
Value
Named list. For input files, the list contains the elementsquarto,engines,formats,resources,fileInformation plusproject if the file ispart of a Quarto project. For projects, the list contains the elementsquarto,dir,engines,config andfiles.
Examples
## Not run: # Inspect input file filequarto_inspect("notebook.Rmd")# Inspect projectquarto_inspect("myproject")# Inspect project's advanced profilequarto_inspect( input = "myproject", profile = "advanced")## End(Not run)List Installed Quarto extensions
Description
List Quarto Extensions in this folder or project by runningquarto list
Usage
quarto_list_extensions()Value
A data frame with the installed extensions or NULL (invisibly) if no extensions are installed.
Examples
## Not run: # List Quarto Extensions in this folder or projectquarto_list_extensions()## End(Not run)Log debug information to a configurable file
Description
This function logs messages to a file only when in debug mode to help diagnoseissues with Quarto vignettes inpkgdown and other contexts.
Usage
quarto_log( ..., file = NULL, append = TRUE, timestamp = TRUE, prefix = "DEBUG: ")Arguments
... | Messages to log (will be concatenated) |
file | Path to log file. If NULL, uses |
append | Logical. Should the messages be appended to the file? Default TRUE. |
timestamp | Logical. Should a timestamp be added? Default TRUE. |
prefix | Character. Prefix to add before each log entry. Default "DEBUG: ". |
Details
Debug mode will be enabled automatically when debugging Github Actions workflows,or when Quarto CLI's environment variableQUARTO_LOG_LEVEL is set toDEBUG.
Value
Invisibly returns TRUE if logging occurred, FALSE otherwise
Configuration
Enable debugging messages:
Set
quarto.log.debug = TRUE(orR_QUARTO_LOG_DEBUG = TRUEenvironment variable)
Change log file path:
Set
quarto.log.fileto change the file path (orR_QUARTO_LOG_FILEenvironment variable)Default will be
./quarto-r-debug.log
Automatic debug mode:
Debug mode will be on automatically when debugging Github Actions workflows
When Quarto CLI's environment variable
QUARTO_LOG_LEVELis set toDEBUG
Examples
## Not run: # Set log file via environment variableSys.setenv(R_QUARTO_LOG_FILE = "~/quarto-debug.log")# Or via optionoptions(quarto.log.file = "~/quarto-debug.log")# Enable debug modeoptions(quarto.log.debug = TRUE)# Log some informationquarto_log("Starting process")quarto_log("R_LIBS:", Sys.getenv("R_LIBS"))quarto_log(".libPaths():", paste0(.libPaths(), collapse = ":"))## End(Not run)Path to the quarto binary
Description
Determine the path to the quarto binary. UsesQUARTO_PATH environmentvariable if defined, otherwise usesSys.which().
Usage
quarto_path(normalize = TRUE)Arguments
normalize | If |
Value
Path to quarto binary (orNULL if not found)
See Also
quarto_version() to check the version of the binary found,quarto_available() to check if Quarto CLI is available and meets some requirements.
Quarto Preview
Description
Render and preview a Quarto document or website project.
Usage
quarto_preview( file = NULL, render = "auto", port = "auto", host = "127.0.0.1", browse = TRUE, watch = TRUE, navigate = TRUE, quiet = FALSE)quarto_preview_stop()Arguments
file | The document or website project directory to preview (defaults tocurrent working directory) |
render | For website preview, the most recent execution results ofcomputational documents are used to render the site (this is to optimizestartup time). If you want to perform a full render prior to serving pass"all" or a vector of specific formats to render. Pass "default" to renderthe default format for the site. For document preview, the document isrendered prior to preview (pass |
port | Port to listen on (defaults to 4848) |
host | Hostname to bind to (defaults to 127.0.0.1) |
browse | Open a browser to preview the content. Defaults to using theRStudio Viewer when running within RStudio.Pass a function (e.g. |
watch | Watch for changes and automatically reload browser. |
navigate | Automatically navigate the preview browser to the mostrecently rendered document. |
quiet | Suppress warning and other messages, from R and also Quarto CLI(i.e |
Details
Automatically reloads the browser when input files are re-rendered ordocument resources (e.g. CSS) change.
Value
The URL of the preview server (invisibly). This can be used toprogrammatically access the server location, for example to take screenshotswith webshot2 or pass to other automation tools.
Examples
## Not run: # Preview the project in the current directoryquarto_preview()# Preview a documentquarto_preview("document.qmd")# Preview the project in "myproj" directory and use external browser# (rather than RStudio Viewer)quarto_preview("myproj", open = utils::browseURL)# Capture the preview URL for programmatic usepreview_url <- quarto_preview("document.qmd", browse = FALSE)cat("Preview available at:", preview_url, "\n")# Take a screenshot of the preview using webshot2if (require(webshot2)) { preview_url <- quarto_preview("document.qmd", browse = FALSE) webshot2::webshot(preview_url, "preview.png")}# Stop any running quarto previewquarto_preview_stop()## End(Not run)Publish Quarto Documents
Description
Publish Quarto documents to Posit Connect, ShinyApps, and RPubs
Usage
quarto_publish_doc( input, name = NULL, title = NULL, server = NULL, account = NULL, render = c("local", "server", "none"), metadata = list(), ...)quarto_publish_app( input = getwd(), name = NULL, title = NULL, server = NULL, account = NULL, render = c("local", "server", "none"), metadata = list(), ...)quarto_publish_site( input = getwd(), name = NULL, title = NULL, server = NULL, account = NULL, render = c("local", "server", "none"), metadata = list(), ...)Arguments
input | The input file or project directory to be published. Defaults tothe current working directory. |
name | Name for publishing (names must be unique within an account).Defaults to the name of the |
title | Free-form descriptive title of application. Optional; ifsupplied, will often be displayed in favor of the name. When deploying a newdocument, you may supply only the title to receive an auto-generated name |
account,server | Uniquely identify a remote server with either youruser Use |
render |
|
metadata | Additional metadata fields to save with the deploymentrecord. These fields will be returned on subsequent calls to Multi-value fields are recorded as comma-separated values and returned inthat form. Custom value serialization is the responsibility of the caller. |
... | Named parameters to pass along to |
Examples
## Not run: library(quarto)quarto_publish_doc("mydoc.qmd")quarto_publish_app(server = "shinyapps.io")quarto_publish_site(server = "rstudioconnect.example.com")## End(Not run)Remove a Quarto extensions
Description
Remove an extension in this folder or project by runningquarto remove
Usage
quarto_remove_extension( extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL)Arguments
extension | The extension name to remove, as in |
no_prompt | Do not prompt to confirm approval to download external extension. |
quiet | Suppress warning and other messages, from R and also Quarto CLI(i.e
On Github Actions, it will always be |
quarto_args | Character vector of other |
Value
Returns invisiblyTRUE if the extension was removed,FALSE otherwise.
See Also
quarto_add_extension() andQuarto Website.
Examples
## Not run: # Remove an already installed extensionquarto_remove_extension("quarto-ext/fontawesome")## End(Not run)Render Markdown
Description
Render the input file to the specified output format using quarto. If theinput requires computations (e.g. for Rmd or Jupyter files) then thosecomputations are performed before rendering.
Usage
quarto_render( input = NULL, output_format = NULL, output_file = NULL, execute = TRUE, execute_params = NULL, execute_dir = NULL, execute_daemon = NULL, execute_daemon_restart = FALSE, execute_debug = FALSE, use_freezer = FALSE, cache = NULL, cache_refresh = FALSE, metadata = NULL, metadata_file = NULL, debug = FALSE, quiet = FALSE, profile = NULL, quarto_args = NULL, pandoc_args = NULL, as_job = getOption("quarto.render_as_job", "auto"))Arguments
input | The input file or project directory to be rendered (defaultsto rendering the project in the current working directory). |
output_format | Target output format (defaults to |
output_file | Base name for single-file output (e.g. PDF, ePub, MS Word).This sets the |
execute | Whether to execute embedded code chunks. |
execute_params | A list of named parameters that override custom paramsspecified within the YAML front-matter. |
execute_dir | The working directory in which to execute embedded codechunks. |
execute_daemon | Keep Jupyter kernel alive (defaults to 300 seconds).Note this option is only applicable for rendering Jupyter notebooks orJupyter markdown. |
execute_daemon_restart | Restart keepalive Jupyter kernel before render.Note this option is only applicable for rendering Jupyter notebooks orJupyter markdown. |
execute_debug | Show debug output for Jupyter kernel. |
use_freezer | Force use of frozen computations for an incrementalfile render. |
cache | Cache execution output (uses knitr cache and jupyter-cacherespectively for Rmd and Jupyter input files). |
cache_refresh | Force refresh of execution cache. |
metadata | An optional named list used to override YAMLmetadata. It will be passed as a YAML file to |
metadata_file | A yaml file passed to |
debug | Leave intermediate files in place after render. |
quiet | Suppress warning and other messages, from R and also Quarto CLI(i.e
On Github Actions, it will always be |
profile | Quarto project profile(s) to use. Eithera character vector of profile names or |
quarto_args | Character vector of other |
pandoc_args | Additional command line arguments to pass on to Pandoc. |
as_job | Render as an RStudio background job. Default is |
Value
Invisibly returnsNULL. The function is called for its side effectof rendering the specified document or project.
Examples
## Not run: # Render R Markdownquarto_render("notebook.Rmd")quarto_render("notebook.Rmd", output_format = "pdf")# Render Jupyter Notebookquarto_render("notebook.ipynb")# Render Jupyter Markdownquarto_render("notebook.md")# Override metadataquarto_render("notebook.Rmd", metadata = list(lang = "fr", execute = list(echo = FALSE)))## End(Not run)Serve Interactive Document
Description
Serve a Shiny interactive document. By default, the document willbe rendered first and then served If you have previously renderedthe document, passrender = FALSE to skip rendering.
Usage
quarto_serve( input, render = TRUE, port = getOption("shiny.port"), host = getOption("shiny.host", "127.0.0.1"), browse = TRUE)Arguments
input | The input file to run. Should be a file witha |
render | Render the document before serving it. |
port | Port to listen on (defaults to 4848) |
host | Hostname to bind to (defaults to 127.0.0.1) |
browse | Open a browser to preview the content. Defaults to using theRStudio Viewer when running within RStudio.Pass a function (e.g. |
Update a Quarto extensions
Description
Update an extension to this folder or project by runningquarto update
Usage
quarto_update_extension( extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL)Arguments
extension | The extension to update, either by its name (i.e |
no_prompt | Do not prompt to confirm approval to download external extension. Setting |
quiet | Suppress warning and other messages, from R and also Quarto CLI(i.e
On Github Actions, it will always be |
quarto_args | Character vector of other |
Value
Returns invisiblyTRUE if the extension was updated,FALSE otherwise.
Extension Trust
Quarto extensions may execute code when documents are rendered. Therefore, ifyou do not trust the author of an extension, we recommend that you do notinstall or use the extension.By defaultno_prompt = FALSE which means thatthe function will ask for explicit approval when used interactively, ordisallow installation.
See Also
quarto_add_extension(),quarto_remove_extension(), andQuarto website.
Examples
## Not run: # Update a template and set up a draft document from a GitHub repositoryquarto_update_extension("quarto-ext/fontawesome")# Update a template and set up a draft document from a ZIP archivequarto_update_extension("https://github.com/quarto-ext/fontawesome/archive/refs/heads/main.zip")## End(Not run)Use a custom format extension template
Description
Install and use a template for Quarto usingquarto use.
Usage
quarto_use_template( template, dir = ".", no_prompt = FALSE, quiet = FALSE, quarto_args = NULL)Arguments
template | The template to install, either an archive or a GitHubrepository as described in the documentationhttps://quarto.org/docs/extensions/formats.html. |
dir | The directory in which to install the template. This must be an empty directory.To use directly in a non-empty directory, use |
no_prompt | Do not prompt to confirm approval to download external extension. |
quiet | Suppress warnings and messages. |
quarto_args | Character vector of other |
Examples
## Not run: # Use a template and set up a draft document from a GitHub repositoryquarto_use_template("quarto-journals/jss")# Use a template in current directory by installing it in an empty directoryquarto_use_template("quarto-journals/jss", dir = "new-empty-dir")# Use a template and set up a draft document from a ZIP archivequarto_use_template("https://github.com/quarto-journals/jss/archive/refs/heads/main.zip")## End(Not run)Check quarto version
Description
Determine the specific version of quarto binary found byquarto_path().If it returns99.9.9 then it means you are using a dev version.
Usage
quarto_version()Value
anumeric_version with the quarto version found
See Also
quarto_available() to check if the version meets some requirements.
Create Quarto Markdown HTML Elements for Tables
Description
Functions to wrap content in HTML spans or divs with data-qmd attributes forQuarto processing within HTML tables. These functions are specifically designedfor use with HTML table packages like kableExtra, gt, or DT where you needQuarto to process markdown content within table cells.
Usage
tbl_qmd_span(content, display = NULL, use_base64 = TRUE)tbl_qmd_div(content, display = NULL, use_base64 = TRUE)tbl_qmd_span_base64(content, display = NULL)tbl_qmd_div_base64(content, display = NULL)tbl_qmd_span_raw(content, display = NULL)tbl_qmd_div_raw(content, display = NULL)Arguments
content | Character string of content to wrap. This can include Markdown,LaTeX math, and Quarto shortcodes. |
display | Optional display text (if different from content). Useful forfallback text when Quarto processing is not available or for betteraccessibility. |
use_base64 | Logical, whether to base64 encode the content (recommendedfor complex content with special characters or when content includes quotes) |
Details
These functions create HTML elements withdata-qmd ordata-qmd-base64attributes that Quarto processes during document rendering. The base64encoding is recommended for content with special characters, quotes, orcomplex formatting.
Available functions:
tbl_qmd_span()andtbl_qmd_div()are the main functions with encoding optionstbl_qmd_span_base64()andtbl_qmd_div_base64()explicitly use base64 encodingtbl_qmd_span_raw()andtbl_qmd_div_raw()explicitly use raw encoding
This feature requires Quarto version 1.3 or higher with HTML format outputs.For more information, seehttps://quarto.org/docs/authoring/tables.html#html-tables.
Value
Character string containing the HTML element with appropriate data-qmd attributes
Examples
# Basic span usage in table cellstbl_qmd_span("**bold text**")tbl_qmd_span("$\\alpha + \\beta$", display = "Greek formula")# Basic div usage in table cellstbl_qmd_div("## Section Title\n\nContent here")tbl_qmd_div("{{< video https://example.com >}}", display = "[Video content]")# Explicit encoding choicestbl_qmd_span_base64("Complex $\\LaTeX$ content")tbl_qmd_span_raw("Simple text")# Use with different HTML table packages## Not run: # With kableExtralibrary(kableExtra)df <- data.frame( math = c(tbl_qmd_span("$x^2$"), tbl_qmd_span("$\\sum_{i=1}^n x_i$")), text = c(tbl_qmd_span("**Important**", "bold"), tbl_qmd_span("`code`", "code")))kbl(df, format = "html", escape = FALSE) |> kable_styling()## End(Not run)Create a theme for a plotting or table package
Description
Create a theme using background and foreground colors (theme_colors_*) orusing abrand.yml file (theme_brand_*).
Usage
theme_colors_flextable(bg, fg)theme_brand_flextable(brand_yml)theme_colors_ggplot2(bg, fg)theme_brand_ggplot2(brand_yml)theme_colors_gt(bg, fg)theme_brand_gt(brand_yml)theme_colors_plotly(bg, fg)theme_brand_plotly(brand_yml)theme_colors_thematic(bg, fg)theme_brand_thematic(brand_yml)Arguments
bg | The background color |
fg | The foreground color |
brand_yml | The path to a brand.yml file |
Details
The use of the theme will depend on the package. Please seelight/dark renderings examplesfor examples using each supported package with dark mode,theme_brand_*,andrenderings: [light, dark],ortheme helper articlefor examples using each package andtheme_colors_* to specify thebackground and foreground colors directly.
Write YAML Metadata Block for Quarto Documents
Description
Creates a YAML metadata block that can be dynamically inserted into Quartodocuments from R code chunks. This allows setting metadata values based onR computations, which can then be used with Quarto's conditional contentfeatures likewhen-meta and{{< meta >}} shortcodes.
Usage
write_yaml_metadata_block(..., .list = NULL)Arguments
... | Named arguments to include in the metadata block. Names becomethe metadata keys and values become the metadata values. These takeprecedence over any conflicting keys in |
.list | Optional list of additional metadata to include. This is usefulwhen you have metadata stored in a list variable. Keys in |
Details
The function converts R values to YAML format and wraps them in YAMLdelimiters (---). Logical values are converted to lowercase strings("true"/"false") to ensure compatibility with Quarto's metadata system.
When both... and.list contain the same key, the value from...takes precedence and will override the value from.list.
If no metadata is provided (empty... andNULL or empty.list),the function returnsNULL without generating any output.
This addresses the limitation where Quarto metadata must be static andcannot be set dynamically from R code during document rendering.
YAML 1.2 Compatibility:
To ensure compatibility with Quarto's YAML 1.2 parser (js-yaml), the functionautomatically handles two key differences between R's yaml package (YAML 1.1)and YAML 1.2:
Boolean values:
R logical values (TRUE/FALSE) are converted to lowercaseYAML 1.2 format (true/false) using [yaml::verbatim_logical()]. This preventsYAML 1.1 boolean representations likeyes/no from being used.
String quoting:
Strings with leading zeros that contain digits 8 or 9 (like"029","089")are automatically quoted to prevent them from being parsed as octal numbers,which would result in data corruption (e.g.,"029" becoming29).Valid octal numbers containing only digits 0-7 (like"0123") are handledby the underlyingyaml package.
For manual control over string quoting behavior, use [yaml_quote_string()].
Quarto Usage:
To use this function in a Quarto document, create an R code chunk withtheoutput: asis option:
```{r}#| output: asiswrite_yaml_metadata_block(admin = TRUE, version = "1.0")Without the `output: asis` option, the YAML metadata block will bedisplayed as text rather than processed as metadata by Quarto.[yaml::verbatim_logical()]: R:yaml::verbatim_logical()[yaml_quote_string()]: R:yaml_quote_string()
Value
A character string containing the formatted YAML metadata block,wrapped withknitr::asis_output() so it renders as raw markdown.ReturnsNULL invisibly if no metadata is provided.
See Also
yaml_quote_string() for explicitly controlling which strings are quotedin YAML output when you encounter edge cases that need manual handling.
Examples
## Not run: # In a Quarto document R chunk with `#| output: asis`:admin <- TRUEuser_level <- "advanced"# Set metadata dynamicallywrite_yaml_metadata_block( admin = admin, level = user_level, timestamp = Sys.Date())# Strings with leading zeros are automatically quoted for YAML 1.2 compatibilitywrite_yaml_metadata_block( zip_code = "029", # Automatically quoted as "029" build_id = "0123" # Quoted by yaml package (valid octal))# Use with .list parametermetadata_list <- list(version = "1.0", debug = FALSE)write_yaml_metadata_block(.list = metadata_list)# Direct arguments override .list valuesbase_config <- list(theme = "dark", debug = TRUE)write_yaml_metadata_block( debug = FALSE, # This overrides debug = TRUE from base_config author = "John", .list = base_config)# Then use in Quarto with conditional content:# ::: {.content-visible when-meta="admin"}# Admin-only content here# :::## End(Not run)YAML character handler for YAML 1.1 to 1.2 compatibility
Description
This handler bridges the gap between R's yaml package (YAML 1.1) andjs-yaml (YAML 1.2) by quoting strings with leading zeros that would bemisinterpreted as octal numbers.
Usage
yaml_character_handler(x)Arguments
x | A character vector |
Details
According to YAML 1.1 spec, octal integers are0o[0-7]+. The R yamlpackage only quotes valid octals (containing only digits 0-7), but js-yamlattempts to parse ANY leading zero string as octal, causing data corruptionfor invalid octals like "029" → 29.
Value
The input with quoted attributes applied where needed
See Also
Add quoted attribute to strings for YAML output
Description
This function allows users to explicitly mark strings that should be quotedin YAML output, giving full control over quoting behavior.
Usage
yaml_quote_string(x)Arguments
x | A character vector or single string |
Details
This is particularly useful for special values that might be misinterpretedasyaml uses YAML 1.1 and Quarto expects YAML 1.2.
Thequoted attribute is a convention used byyaml::as.yaml()
Value
The input with quoted attributes applied
Examples
yaml::as.yaml(list(id = yaml_quote_string("1.0")))yaml::as.yaml(list(id = "1.0"))