-
Notifications
You must be signed in to change notification settings - Fork 42
/
render.sh
53 lines (48 loc) · 1.83 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# ref: http://rmarkdown.rstudio.com/revealjs_presentation_format.html
parent_dir="$(pwd)"
git_repo_url="https://github.com/c4pr1c3/reveal.js.git"
css_src_file="${parent_dir}/reveal.js/css/reveal.css"
css_min_file="reveal.js/css/reveal.min.css"
js_src_file="${parent_dir}/reveal.js/js/reveal.js"
js_min_file="reveal.js/js/reveal.min.js"
if [[ "$1" == "gitee" ]];then
git_repo_url="https://gitee.com/c4pr1c3/reveal.js"
fi
if [ ! -f "${css_src_file}" ] || [ ! -f "${js_src_file}" ];then
# download reveal.js repo
git_tmp=$(mktemp -d)
echo "git cloning ${git_repo_url}"
if [[ -z $(git --git-dir="${git_tmp}" clone --depth=1 ${git_repo_url} 2>&1) ]];then
echo "Done with git clone ${git_repo_url}"
else
echo "Failed with git clone ${git_repo_url}"
exit 1
fi
else
echo "reveal.js is installed"
fi
if [[ ! -e "${css_min_file}" ]];then
ln -s "${css_src_file}" "${css_min_file}"
fi
if [[ ! -e "${js_min_file}" ]];then
ln -s "${js_src_file}" "${js_min_file}"
fi
if [[ -x $(command -v pandoc) ]];then
for input in ./*.md;do
if [[ "$input" == "./README.md" ]];then
continue
fi
output_ppt="${input}.html"
output_html="${input}.print.html"
pandoc -t revealjs --template=revealjs.template.html -s "${input}" -V theme=white -V transition=fade -V incremental=true -V slideNumber=true -o "${output_ppt}" -V revealjs-url="reveal.js" -V history=true --no-highlight -V hlss=zenburn -V mathjax=true
echo "generated presentation file: ${output_ppt}"
pandoc -t html5 -s "${input}" -V theme=white -V transition=fade -V incremental=true -V slideNumber=true -o "${output_html}" -V revealjs-url="reveal.js" -V history=true
echo "generated presentation file: ${output_html}"
done
# 生成默认首页
pandoc index.md -s -o index.html
else
echo "You need to install pandoc to run this script"
exit 1
fi