Debian Codegraph @

man/knit_patterns.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/pattern.R
3 \docType{data}
4 \name{knit_patterns}
5 \alias{knit_patterns}
6 \title{Patterns to match and extract R code in a document}
7 \format{
8 An object of class \code{list} of length 7.
9 }
10 \usage{
11 knit_patterns
12 }
13 \description{
14 Patterns are regular expressions and will be used in functions like
15 \code{base::\link{grep}()} to extract R code and chunk options. The object
16 \code{knit_patterns} controls the patterns currently used; see the references
17 and examples for usage. All built-in patterns are available in the list
18 \link{all_patterns}.
19 }
20 \examples{
21 library(knitr)
22 opat = knit_patterns$get() # old pattern list (to restore later)
23
24 apats = all_patterns # a list of all built-in patterns
25 str(apats)
26 knit_patterns$set(apats[["rnw"]]) # set pattern list from apats
27
28 knit_patterns$get(c("chunk.begin", "chunk.end", "inline.code"))
29
30 # a customized pattern list; has to empty the original patterns first!
31 knit_patterns$restore()
32 # we may want to use this in an HTML document
33 knit_patterns$set(list(chunk.begin = "<!--helloR\\\\s+(.*)", chunk.end = "^byeR-->"))
34 str(knit_patterns$get())
35
36 knit_patterns$set(opat) # put the old patterns back
37 }
38 \references{
39 Usage: \url{https://yihui.org/knitr/objects/}
40
41 Components in \code{knit_patterns}: \url{https://yihui.org/knitr/patterns/}
42 }
43 \seealso{
44 \code{\link{all_patterns}}
45 }
46 \keyword{datasets}