% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cli.R
\name{cli_code}
\alias{cli_code}
\title{A block of code}
\usage{
cli_code(
  lines = NULL,
  ...,
  language = "R",
  .auto_close = TRUE,
  .envir = environment()
)
}
\arguments{
\item{lines}{Chracter vector, each line will be a line of code, and
newline charactes also create new lines. Note that \emph{no} glue
substitution is performed on the code.}

\item{...}{More character vectors, they are appended to \code{lines}.}

\item{language}{Programming language. This is also added as a class,
in addition to \code{code}.}

\item{.auto_close}{Passed to \code{cli_div()} when creating the container of
the code. By default the code container is closed after emitting
\code{lines} and \code{...} via \code{cli_verbatim()}. You can keep that container
open with \code{.auto_close} and/or \code{.envir}, and then calling
\code{cli_verbatim()} to add (more) code. Note that the code will be
formatted and syntax highlighted separately for each \code{cli_verbatim()}
call.}

\item{.envir}{Passed to \code{cli_div()} when creating the container of the
code.}
}
\value{
The id of the container that contains the code.
}
\description{
A helper function that creates a \code{div} with class \code{code} and then calls
\code{cli_verbatim()} to output code lines. The builtin theme formats these
containers specially. In particular, it adds syntax highlighting to
valid R code.
}
\examples{
cli_code(format(cli::cli_blockquote))
}
