Title: | R Interface to 'Quarto' Markdown Publishing System |
---|---|
Description: | Convert R Markdown documents and 'Jupyter' notebooks to a variety of output formats using 'Quarto'. |
Authors: | JJ Allaire [aut] , Christophe Dervieux [cre, aut] , Posit Software, PBC [cph, fnd] |
Maintainer: | Christophe Dervieux <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.4.4 |
Built: | 2024-10-31 19:48:26 UTC |
Source: | CRAN |
This function will check if a directory is using quarto by looking for
_quarto.yml
at its root
at least one .qmd
file in the directory
is_using_quarto(dir = ".", verbose = FALSE)
is_using_quarto(dir = ".", verbose = FALSE)
dir |
The directory to check |
verbose |
print message about the result of the check |
dir.create(tmpdir <- tempfile()) is_using_quarto(tmpdir) file.create(file.path(tmpdir, "_quarto.yml")) is_using_quarto(tmpdir) unlink(tmpdir, recursive = TRUE)
dir.create(tmpdir <- tempfile()) is_using_quarto(tmpdir) file.create(file.path(tmpdir, "_quarto.yml")) is_using_quarto(tmpdir) unlink(tmpdir, recursive = TRUE)
Add an extension to this folder or project by running quarto add
quarto_add_extension( extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL )
quarto_add_extension( extension = NULL, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL )
extension |
The extension to install, either an archive or a GitHub repository as described in the documentation https://quarto.org/docs/extensions/managing.html. |
no_prompt |
Do not prompt to confirm approval to download external extension. |
quiet |
Suppress warning and other messages. |
quarto_args |
Character vector of other |
Quarto extensions may execute code when documents are rendered. Therefore, if
you do not trust the author of an extension, we recommend that you do not
install or use the extension.
By default no_prompt = FALSE
which means that
the function will ask for explicit approval when used interactively, or
disallow installation.
## Not run: # Install a template and set up a draft document from a GitHub repository quarto_add_extension("quarto-ext/fontawesome") # Install a template and set up a draft document from a ZIP archive quarto_add_extension("https://github.com/quarto-ext/fontawesome/archive/refs/heads/main.zip") ## End(Not run)
## Not run: # Install a template and set up a draft document from a GitHub repository quarto_add_extension("quarto-ext/fontawesome") # Install a template and set up a draft document from a ZIP archive quarto_add_extension("https://github.com/quarto-ext/fontawesome/archive/refs/heads/main.zip") ## End(Not run)
This function check the configuration for the quarto package R package to detect a possible difference with version used by RStudio IDE.
quarto_binary_sitrep(verbose = TRUE, debug = FALSE)
quarto_binary_sitrep(verbose = TRUE, debug = FALSE)
verbose |
if |
debug |
if |
TRUE
if this package should be using the same quarto binary as the
RStudio IDE. FALSE
otherwise if a difference is detected or quarto is not
found. Use verbose = TRUE
ordebug = TRUE
to get detailed information.
quarto_binary_sitrep(verbose = FALSE) quarto_binary_sitrep(verbose = TRUE) quarto_binary_sitrep(debug = TRUE)
quarto_binary_sitrep(verbose = FALSE) quarto_binary_sitrep(verbose = TRUE) quarto_binary_sitrep(debug = TRUE)
This function calls quarto create project <type> <name>
. It will create a
new directory with the project name and add some skeletons files for the
project type chosen.
quarto_create_project( name, type = "default", dir = ".", no_prompt = FALSE, quiet = FALSE, quarto_args = NULL )
quarto_create_project( name, type = "default", dir = ".", no_prompt = FALSE, quiet = FALSE, quarto_args = NULL )
name |
The name of the project and the directory that will be created. |
type |
The type of project to create. As of 1.4, it can be one of
|
dir |
The directory where to create the new Quarto project. |
no_prompt |
Do not prompt to confirm approval to download external extension. |
quiet |
Suppress warning and other messages. |
quarto_args |
Character vector of other |
This function require Quarto 1.4 or higher. Use quarto_version()
to check
the version of Quarto detected.
Quarto documentation on Quarto projects
Inspect a Quarto project or input path. Inspecting a project returns its config and engines. Inspecting an input path return its formats, engine, and dependent resources.
quarto_inspect(input = ".", profile = NULL, quiet = FALSE, quarto_args = NULL)
quarto_inspect(input = ".", profile = NULL, quiet = FALSE, quarto_args = NULL)
input |
The input file or project directory to inspect. |
profile |
Quarto project profile(s) to use. Either
a character vector of profile names or |
quiet |
Suppress warning and other messages. |
quarto_args |
Character vector of other |
Named list. For input files, the list contains the elements
quarto
, engines
, formats
, resources
, plus project
if the file is
part of a Quarto project. For projects, the list contains the elements
quarto
, dir
, engines
, config
and files
.
## Not run: # Inspect input file file quarto_inspect("notebook.Rmd") # Inspect project quarto_inspect("myproject") # Inspect project's advanced profile quarto_inspect( input = "myproject", profile = "advanced" ) ## End(Not run)
## Not run: # Inspect input file file quarto_inspect("notebook.Rmd") # Inspect project quarto_inspect("myproject") # Inspect project's advanced profile quarto_inspect( input = "myproject", profile = "advanced" ) ## End(Not run)
Determine the path to the quarto binary. Uses QUARTO_PATH
environment
variable if defined, otherwise uses Sys.which()
.
quarto_path()
quarto_path()
Path to quarto binary (or NULL
if not found)
Render and preview a Quarto document or website project.
quarto_preview( file = NULL, render = "auto", port = "auto", host = "127.0.0.1", browse = TRUE, watch = TRUE, navigate = TRUE ) quarto_preview_stop()
quarto_preview( file = NULL, render = "auto", port = "auto", host = "127.0.0.1", browse = TRUE, watch = TRUE, navigate = TRUE ) quarto_preview_stop()
file |
The document or website project directory to preview (defaults to current working directory) |
render |
For website preview, the most recent execution results of
computational documents are used to render the site (this is to optimize
startup 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 render
the default format for the site. For document preview, the document is
rendered 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 the
RStudio 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 most recently rendered document. |
Automatically reloads the browser when input files are re-rendered or document resources (e.g. CSS) change.
## Not run: # Preview the project in the current directory quarto_preview() # Preview a document quarto_preview("document.qmd") # Preview the project in "myproj" directory and use external browser # (rather than RStudio Viewer) quarto_preview("myproj", open = utils::browseURL) # Stop any running quarto preview quarto_preview_stop() ## End(Not run)
## Not run: # Preview the project in the current directory quarto_preview() # Preview a document quarto_preview("document.qmd") # Preview the project in "myproj" directory and use external browser # (rather than RStudio Viewer) quarto_preview("myproj", open = utils::browseURL) # Stop any running quarto preview quarto_preview_stop() ## End(Not run)
Publish Quarto documents to Posit Connect, ShinyApps, and RPubs
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(), ... )
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(), ... )
input |
The input file or project directory to be published. Defaults to the 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; if supplied, will often be displayed in favor of the name. When deploying a new document, you may supply only the title to receive an auto-generated name |
account , server
|
Uniquely identify a remote server with either your
user Use |
render |
|
metadata |
Additional metadata fields to save with the deployment
record. These fields will be returned on subsequent calls to
Multi-value fields are recorded as comma-separated values and returned in that form. Custom value serialization is the responsibility of the caller. |
... |
Named parameters to pass along to |
## 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)
## 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)
Render the input file to the specified output format using quarto. If the input requires computations (e.g. for Rmd or Jupyter files) then those computations are performed before rendering.
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") )
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") )
input |
The input file or project directory to be rendered (defaults to rendering the project in the current working directory). |
output_format |
Target output format (defaults to |
output_file |
The name of the output file. If using |
execute |
Whether to execute embedded code chunks. |
execute_params |
A list of named parameters that override custom params specified within the YAML front-matter. |
execute_dir |
The working directory in which to execute embedded code chunks. |
execute_daemon |
Keep Jupyter kernel alive (defaults to 300 seconds). Note this option is only applicable for rendering Jupyter notebooks or Jupyter markdown. |
execute_daemon_restart |
Restart keepalive Jupyter kernel before render. Note this option is only applicable for rendering Jupyter notebooks or Jupyter markdown. |
execute_debug |
Show debug output for Jupyter kernel. |
use_freezer |
Force use of frozen computations for an incremental file render. |
cache |
Cache execution output (uses knitr cache and jupyter-cache respectively for Rmd and Jupyter input files). |
cache_refresh |
Force refresh of execution cache. |
metadata |
An optional named list used to override YAML
metadata. 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. |
profile |
Quarto project profile(s) to use. Either
a 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 |
## Not run: # Render R Markdown quarto_render("notebook.Rmd") quarto_render("notebook.Rmd", output_format = "pdf") # Render Jupyter Notebook quarto_render("notebook.ipynb") # Render Jupyter Markdown quarto_render("notebook.md") # Override metadata quarto_render("notebook.Rmd", metadata = list(lang = "fr", execute = list(echo = FALSE))) ## End(Not run)
## Not run: # Render R Markdown quarto_render("notebook.Rmd") quarto_render("notebook.Rmd", output_format = "pdf") # Render Jupyter Notebook quarto_render("notebook.ipynb") # Render Jupyter Markdown quarto_render("notebook.md") # Override metadata quarto_render("notebook.Rmd", metadata = list(lang = "fr", execute = list(echo = FALSE))) ## End(Not run)
Serve a Shiny interactive document. By default, the document will
be rendered first and then served If you have previously rendered
the document, pass render = FALSE
to skip rendering.
quarto_serve( input, render = TRUE, port = getOption("shiny.port"), host = getOption("shiny.host", "127.0.0.1"), browse = TRUE )
quarto_serve( input, render = TRUE, port = getOption("shiny.port"), host = getOption("shiny.host", "127.0.0.1"), browse = TRUE )
input |
The input file to run. Should be a file with
a |
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 the
RStudio Viewer when running within RStudio.Pass a function (e.g.
|
Install and use a template for Quarto using quarto use
.
quarto_use_template( template, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL )
quarto_use_template( template, no_prompt = FALSE, quiet = FALSE, quarto_args = NULL )
template |
The template to install, either an archive or a GitHub repository as described in the documentation https://quarto.org/docs/extensions/formats.html. |
no_prompt |
Do not prompt to confirm approval to download external extension. |
quiet |
Suppress warnings and messages. |
quarto_args |
Character vector of other |
## Not run: # Install a template and set up a draft document from a GitHub repository quarto_use_template("quarto-journals/jss") # Install a template and set up a draft document from a ZIP archive quarto_use_template("https://github.com/quarto-journals/jss/archive/refs/heads/main.zip") ## End(Not run)
## Not run: # Install a template and set up a draft document from a GitHub repository quarto_use_template("quarto-journals/jss") # Install a template and set up a draft document from a ZIP archive quarto_use_template("https://github.com/quarto-journals/jss/archive/refs/heads/main.zip") ## End(Not run)
Determine the specific version of quarto binary found by quarto_path()
.
If it returns 99.9.9
then it means you are using a dev version.
quarto_version()
quarto_version()
a numeric_version
with the quarto version found