-
Notifications
You must be signed in to change notification settings - Fork 2
/
render.sh
executable file
·38 lines (36 loc) · 1.27 KB
/
render.sh
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
#!/bin/sh
if [[ $# -eq 0 ]]; then
echo "----------------------------------------------------------------------"
echo "Rendering HTML"
echo
echo "If you want to render the PDF, set the pdf flag"
echo
echo " ./render.sh pdf"
echo "----------------------------------------------------------------------"
echo
Rscript -e 'bookdown::render_book("index.Rmd")'
elif [ $1 == "pdf" ]; then
echo
echo "Rendering PDF"
echo
# Temporarily changing pdf for gitbook
sed -i '' 's/^[ \t]*# \(beaver.*pdf.*$\)/ \1/' index.Rmd
sed -i '' 's/^[ \t]*\(beaver.*gitbook.*$\)/ # \1/' index.Rmd
# Rendering the book
Rscript -e 'bookdown::render_book("index.Rmd")'
# Changing things back to the way they were
sed -i '' 's/^[ \t]*\(beaver.*pdf.*$\)/ # \1/' index.Rmd
sed -i '' 's/^[ \t]*# \(beaver.*gitbook.*$\)/ \1/' index.Rmd
elif [ $1 == "word" ]; then
echo
echo "Rendering DOCX"
echo
# Temporarily changing pdf for gitbook
sed -i '' 's/^[ \t]*# \(beaver.*word.*$\)/ \1/' index.Rmd
sed -i '' 's/^[ \t]*\(beaver.*gitbook.*$\)/ # \1/' index.Rmd
# Rendering the book
Rscript -e 'bookdown::render_book("index.Rmd")'
# Changing things back to the way they were
sed -i '' 's/^[ \t]*\(beaver.*word.*$\)/ # \1/' index.Rmd
sed -i '' 's/^[ \t]*# \(beaver.*gitbook.*$\)/ \1/' index.Rmd
fi