EVOLUTION-MANAGER
Edit File: cli_code.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: A block of code</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for cli_code {cli}"><tr><td>cli_code {cli}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>A block of code</h2> <h3>Description</h3> <p>A helper function that creates a <code>div</code> with class <code>code</code> and then calls <code>cli_verbatim()</code> to output code lines. The builtin theme formats these containers specially. In particular, it adds syntax highlighting to valid R code. </p> <h3>Usage</h3> <pre> cli_code( lines = NULL, ..., language = "R", .auto_close = TRUE, .envir = environment() ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>lines</code></td> <td> <p>Character vector, each line will be a line of code, and newline characters also create new lines. Note that <em>no</em> glue substitution is performed on the code.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>More character vectors, they are appended to <code>lines</code>.</p> </td></tr> <tr valign="top"><td><code>language</code></td> <td> <p>Programming language. This is also added as a class, in addition to <code>code</code>.</p> </td></tr> <tr valign="top"><td><code>.auto_close</code></td> <td> <p>Passed to <code>cli_div()</code> when creating the container of the code. By default the code container is closed after emitting <code>lines</code> and <code>...</code> via <code>cli_verbatim()</code>. You can keep that container open with <code>.auto_close</code> and/or <code>.envir</code>, and then calling <code>cli_verbatim()</code> to add (more) code. Note that the code will be formatted and syntax highlighted separately for each <code>cli_verbatim()</code> call.</p> </td></tr> <tr valign="top"><td><code>.envir</code></td> <td> <p>Passed to <code>cli_div()</code> when creating the container of the code.</p> </td></tr> </table> <h3>Details</h3> <div class="sourceCode r"><pre>myfun <- function() { message("Just an example function") graphics::pairs(iris, col = 1:4) } cli_code(format(myfun)) </pre></div> <div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre> #> <span style="color: #DC322F;">function</span> <span style="color: #B58900;">()</span> #> <span style="color: #B58900;">{</span> #> <span style="color: #2AA198;">message</span><span style="color: #268BD2;">(</span><span style="color: #B58900;">"Just an example function"</span><span style="color: #268BD2;">)</span> #> graphics::<span style="color: #2AA198;">pairs</span><span style="color: #268BD2;">(</span>iris, col = <span style="color: #268BD2;">1</span><span style="color: #859900;">:</span><span style="color: #268BD2;">4)</span> #> <span style="color: #B58900;">}</span> </pre></div> <h3>Value</h3> <p>The id of the container that contains the code. </p> <hr /><div style="text-align: center;">[Package <em>cli</em> version 3.4.1 <a href="00Index.html">Index</a>]</div> </body></html>