-
Notifications
You must be signed in to change notification settings - Fork 8
/
make_orientation.R
56 lines (43 loc) · 1.32 KB
/
make_orientation.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
48
49
50
51
52
53
54
55
56
# load libraries ----
library(knitr) # install.packages("knitr")
library(rmarkdown)
library(stringr)
# Also required if you get the pdflatex error: www.tug.org/mactex
# set variables ----
title = 'The Ocean Health Index Orientation'
wd = '~/github/ohimanual/0_orientation'
in_md = c(
'0_Welcome.md',
# 'Phase_0.md', # currently this file is in 0_orientation; JSL not sure it fits here?
# 'Phase_1.md'
# 'Phase_2.md'
# 'Phase_3.md'
# 'Phase_4.md'
'0_glossary.md'
)
out_md = 'ohi-orientation.md'
# helper functions ----
cat_md = function(
files_md = setdiff(list.files(getwd(), glob2rx('*.md')), out_md),
out_md = '_all_.md'){
if (file.exists(out_md)) unlink(out_md)
cat('---\n', 'title: ', title, '\n---\n\n', sep='', file=out_md, append=T)
for (md in files_md){
cat(paste(c(readLines(md),'',''), collapse='\n'), file=out_md, append=T)
}
}
# concatenate md ----
setwd(wd)
cat_md(in_md, out_md)
pfx = tools::file_path_sans_ext(out_md)
# render pdf ----
render(
out_md,
pdf_document(
toc = T, toc_depth = 3, number_sections = T,
fig_width = 6.5, fig_height = 4.5, fig_crop = TRUE,
fig_caption = T, highlight = "default", template = "default",
keep_tex = F, latex_engine = "pdflatex",
includes = NULL, pandoc_args = NULL),
clean=T, quiet=F,
output_file = paste0(pfx, '.pdf'))