-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_styles.Rmd
38 lines (33 loc) · 1.04 KB
/
_styles.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
34
35
36
37
38
```{r, setup, include=FALSE}
options(width=200)
hook1 <- function(x){ gsub("```\n*```r*\n*", "", x) }
hook2 <- function(x){ gsub("```\n+```\n", "", x) }
knitr::knit_hooks$set(document = hook2)
knitr::opts_chunk$set(comment = NA)
knitr::opts_chunk$set(collapse = TRUE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::knit_hooks$set(
source = function(x, options) {
hook.r = function(x, options) {
fence <- "```"
language = tolower(options$engine)
if (language == 'node') language = 'javascript'
if (!options$highlight) language = 'text'
if(!is.null(options$foldcode)) {
paste0('\n\n', "<details><summary>View code</summary>\n", fence, language, '\n', x, fence, '\n\n', "</details>\n")
} else {
paste0('\n\n', fence, language, '\n', x, fence, '\n\n')
}
}
x = knitr:::hilight_source(x, 'markdown', options)
hook.r(
paste(c(
x,
''
), collapse = '\n'),
options
)
}
)
```