-
Notifications
You must be signed in to change notification settings - Fork 16
/
style.R
48 lines (42 loc) · 1.55 KB
/
style.R
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
39
40
41
42
43
44
45
46
47
# Knitr settings
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, autodep = TRUE,
dev = 'png', fig.width = 10, fig.height = 10)
knitr::opts_chunk$set(fig.align = "center")
options(crayon.enabled = TRUE, tibble.max_extra_cols = 10)
# Citation options (might not be used)
library("knitcitations")
cite_options(citation_format = "pandoc", max.names = 3, style = "html", hyperlink = "to.doc")
bib <- read.bibtex("bibtexlib.bib")
# Knitr hooks
knitr::knit_hooks$set(
hide_button = function(before, options, envir) {
if (is.character(options$hide_button)) {
button_text = options$hide_button
} else {
button_text = "Show solution"
}
block_label <- paste0("hide_button", options$label)
if (before) {
return(paste0(sep = "\n",
'<button class="btn btn-danger" data-toggle="collapse" data-target="#', block_label, '"> ', button_text, ' </button>\n',
'<div id="', block_label, '" class="collapse">\n'))
} else {
return("</div><br />\n")
}
},
output = function(x, options){
x <- gsub(x, pattern = "<", replacement = "<")
x <- gsub(x, pattern = ">", replacement = ">")
paste0(
"<pre class=\"r-output\"><code>",
fansi::sgr_to_html(x = x, warn = TRUE, term.cap = "256"),
# ansistrings::ansi_to_html(text = x, fullpage = FALSE),
"</code></pre>"
)
}
)
# Display settings
options(width = 100)
# Glossary settings
library(glossary)
gloss <- glossary(definitions_path = "_glossary_definitions.Rmd", glossary_path = "00--glossary.Rmd")