Opens a Quarto project's pre-rendered output of the specified format
in the RStudio viewer pane or the system's default application. For "html"
, a local
HTTP server is launched that serves the HTML output on 127.0.0.1:3456
by default.
This is considerably faster and more responsive than quarto::quarto_preview()
(which runs Quarto in the background and automatically reloads the browser
when input files or document resources (e.g. CSS) change).
Usage
view_output(
input = ".",
output_format = "html",
profile = NULL,
host = "127.0.0.1",
port = 3456L,
in_rstudio_viewer = interactive()
)
Arguments
- input
Path to a Quarto project directory. A character scalar.
- output_format
Quarto output format to open. If
"html"
, a local HTTP server is launched serving the projects's HTML output underhost
on the specifiedport
.- profile
Quarto project profile(s) to use. Either a character vector of profile names or
NULL
to use the default profile.- host
IPv4 address to serve the HTML output on. A character scalar. Only relevant for
format = "html"
.- port
TCP port number to serve the HTML output on. An integer scalar. Note that on most Unix-like systems including Linux and macOS, port numbers below 1024 require root privileges. If the specified
port
is already occupied, a randomly chosen port between 1025–49151 is used instead. Only relevant forformat = "html"
.- in_rstudio_viewer
Whether to open the output file in the RStudio viewer pane if possible, i.e. RStudio is available. If
FALSE
or RStudio is unavailable, the output file is opened in the system's default application foroutput_format
viaxopen::xopen()
instead. Note that only PDFs within the R session temporary directory can be opened in RStudio's viewer pane, others are automatically passed to the system's default PDF viewer.
Value
For format = "html"
, a httpuv::WebServer
object. For format = "pdf"
, the path to the PDF file. Invisibly in both cases.
Details
Note that the web server started by view_output()
will continue running in the background until it is explicitly stopped (e.g. via httpuv::stopServer()
or httpuv::stopAllServers()
) or the R session is terminated. An already running web server on port
is reused if possible (i.e. if it was launched in the
same R session), otherwise a port within the range 1024–49151 ("user" or "registered" ports) is randomly
chosen using httpuv::randomPort()
.