-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.R
35 lines (33 loc) · 1.36 KB
/
build.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
local({
# fall back on '/' if baseurl is not specified
baseurl = servr:::jekyll_config('.', 'baseurl', '/')
knitr::opts_knit$set(base.url = baseurl)
# fall back on 'kramdown' if markdown engine is not specified
markdown = servr:::jekyll_config('.', 'markdown', 'kramdown')
# see if we need to use the Jekyll render in knitr
if (markdown == 'kramdown') {
knitr::render_jekyll()
} else knitr::render_markdown()
# input/output filenames are passed as two additional arguments to Rscript
a = commandArgs(TRUE)
d = gsub('^_|[.][a-zA-Z]+$', '', a[1])
knitr::opts_chunk$set(
fig.path = sprintf('figure/%s/', d),
cache.path = sprintf('cache/%s/', d)
)
# set where you want to host the figures (I store them in my Dropbox Public
# folder, and you might prefer putting them in GIT)
if (Sys.getenv('USER') %in% c('hoehle','me')) {
# these settings are only for myself, and they will not apply to you, but
# you may want to adapt them to your own website
knitr::opts_knit$set(
## base.dir = '/Users/hoehle/Sandbox/Blog/',
## base.url = 'http://hoehleatsu.github.io/'
base.dir = '/Users/hoehle/Sandbox/Blog/',
## base.url = 'http://staff.math.su.se/hoehle/blog/'
base.url = '{{ site.baseurl }}/'
)
}
knitr::opts_knit$set(width = 70)
knitr::knit(a[1], a[2], quiet = TRUE, encoding = 'UTF-8', envir = .GlobalEnv)
})