-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.sh
executable file
·100 lines (78 loc) · 1.8 KB
/
build.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/zsh
autoload -U colors
colors
OUTPUT_DIR=.
TOC_TITLE=
typeset -la FILES
function info {
echo "${fg_bold[green]}-- ${fg_no_bold[white]}$@${reset_color}"
}
function usage {
echo "usage: $1 [options] <file> [<file> [<file> …] …]"
echo
echo "options:"
echo " -o <dir>, --output <dir> Export files to <dir>."
echo " -t <title>, --toc-title <title> Sets the table of contents’ title to <title>"
echo " -h, --help Prints this message."
}
while (( $# > 0 )); do
case "$1" in
-h|--help)
usage "$0"
exit 0
;;
-t|--toc-title)
[[ -n "$2" ]] || {
usage "$0"
exit 1
}
TOC_TITLE="$2"
shift 1
;;
-o|--output|--output-dir)
[[ -n "$2" ]] || {
usage "$0"
exit 1
}
OUTPUT_DIR="$2"
shift 1
;;
-*)
echo "unknown parameter: $1" >&2
exit 2
;;
*)
FILES+=("$1")
;;
esac
shift 1
done
if (( ${#FILES[@]} == 0 )); then
usage
exit 1
fi
for FILE in "${FILES[@]}"; do
FILE="${FILE%.md}"
info "Generating ${FILE}.html"
pandoc ${FILE}.md -o $OUTPUT_DIR/${FILE}.html \
--template template.html -N \
--css=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css \
--css=pv.css --toc
info "Generating ${FILE}.7"
pandoc ${FILE}.md -o $OUTPUT_DIR/${FILE}.7 -s --toc
info "Generating ${FILE}.docx"
pandoc ${FILE}.md -o $OUTPUT_DIR/${FILE}.docx -s --toc
info "Generating ${FILE}.odt"
pandoc ${FILE}.md -o $OUTPUT_DIR/${FILE}.odt -s --toc
info "Generating ${FILE}.epub"
pandoc ${FILE}.md -o $OUTPUT_DIR/${FILE}.epub -s --toc
info "Generating ${FILE}.pdf"
pandoc ${FILE}.md -o $OUTPUT_DIR/${FILE}.pdf \
--latex-engine=xelatex \
-H header.tex \
--template template.tex \
-N \
${TOC_TITLE+-V toc-title="${TOC_TITLE}"} \
-V babel-otherlangs=french \
-V documentclass=article --toc
done