-
-
Notifications
You must be signed in to change notification settings - Fork 226
/
_knitr-options.Rmd
33 lines (30 loc) · 1.35 KB
/
_knitr-options.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# (APPENDIX) Appendix {-}
# **knitr**'s Chunk and Package Options {#full-options}
```{r, echo=FALSE, results='asis'}
# retrieve md from knitr's website; I have cloned the website repo locally, so
# I'll read the local .md file; if you don't want to clone the repo, you may
# read from Github
url = '../yihui.org/content/knitr/options.md'
# system('git clone [email protected]:rbind/yihui.git ../yihui.org')
if (!file.exists(url)) url = 'https://raw.githubusercontent.com/rbind/yihui/master/content/knitr/options.md'
txt = xfun::read_utf8(url)
# remove YAML
txt = txt[(which(txt == '---')[2] + 1):length(txt)]
txt = sub('This page documents', 'This appendix describes', txt)
txt = sub('the "Code Decoration" section', 'Section \\@ref(code-decoration)', txt, fixed = TRUE)
txt = sub('## Chunk Options', '## Chunk options {#chunk-options-full}', txt)
txt = sub('## Package Options', '## Package options', txt)
txt = sub('### Animation', '### Animation {#animation-options}', txt)
txt = sub('### Cache', '### Cache {#cache-options}', txt)
# resolve relative URLs to absolute URLs
m = gregexpr('(?<=]\\()[^)]+(?=\\))', txt, perl = TRUE)
regmatches(txt, m) = lapply(regmatches(txt, m), function(x) {
i = grepl('/', x)
if (length(x[i]) == 0) return(x)
i = i & !grepl('^http', x)
x[i] = sub('^[.][.]/', 'https://yihui.org/knitr/', x[i])
x
})
# output raw text
cat(txt, sep = '\n')
```