EVOLUTION-MANAGER
Edit File: knit_patterns.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: Patterns to match and extract R code in a document</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 knit_patterns {knitr}"><tr><td>knit_patterns {knitr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Patterns to match and extract R code in a document</h2> <h3>Description</h3> <p>Patterns are regular expressions and will be used in functions like <code>base::<a href="../../base/html/grep.html">grep</a>()</code> to extract R code and chunk options. The object <code>knit_patterns</code> controls the patterns currently used; see the references and examples for usage. All built-in patterns are available in the list <a href="all_patterns.html">all_patterns</a>. </p> <h3>Usage</h3> <pre> knit_patterns </pre> <h3>Format</h3> <p>An object of class <code>list</code> of length 6. </p> <h3>References</h3> <p>Usage: <a href="https://yihui.org/knitr/objects/">https://yihui.org/knitr/objects/</a> </p> <p>Components in <code>knit_patterns</code>: <a href="https://yihui.org/knitr/patterns/">https://yihui.org/knitr/patterns/</a> </p> <h3>See Also</h3> <p><code><a href="all_patterns.html">all_patterns</a></code> </p> <h3>Examples</h3> <pre> library(knitr) opat = knit_patterns$get() # old pattern list (to restore later) apats = all_patterns # a list of all built-in patterns str(apats) knit_patterns$set(apats[["rnw"]]) # set pattern list from apats knit_patterns$get(c("chunk.begin", "chunk.end", "inline.code")) # a customized pattern list; has to empty the original patterns first! knit_patterns$restore() # we may want to use this in an HTML document knit_patterns$set(list(chunk.begin = "<!--helloR\\s+(.*)", chunk.end = "^byeR-->")) str(knit_patterns$get()) knit_patterns$set(opat) # put the old patterns back </pre> <hr /><div style="text-align: center;">[Package <em>knitr</em> version 1.29 <a href="00Index.html">Index</a>]</div> </body></html>