-
Notifications
You must be signed in to change notification settings - Fork 6
/
pandoc.sh
executable file
·61 lines (57 loc) · 1.5 KB
/
pandoc.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
#!/bin/sh
if test -z "${1}"
then
echo "Specify a format (pdf, html, docx, odt, all)"
exit
fi
pandoc_html () {
echo "Generating ${1}..."
time pandoc \
--filter=pantable \
--from=markdown+header_attributes \
--to="${1}" \
--pdf-engine=weasyprint \
--section-divs \
--tab-stop=2 \
--table-of-contents \
--toc-depth=2 \
--css=conversions/cc-srd5.css \
--metadata title="System Reference Document 5.1" \
--template=conversions/cc-srd5.html.template \
--wrap=preserve \
--embed-resources \
--standalone \
cc-srd5.md \
--output=conversions/cc-srd5."${1}"
}
pandoc_docx () {
if test -z "${2}"
then
# Pandoc doesn't convert the HTML tables in Markdown to DOCX/ODT, so we
# have to use the HTML output as an intermediary.
echo "Need HTML output..."
pandoc_html html
fi
echo "Generating ${1}..."
time pandoc \
--from=html \
--to="${1}" \
--reference-doc=conversions/custom-reference."${1}" \
--embed-resources \
--standalone \
conversions/cc-srd5.html \
--output=conversions/cc-srd5."${1}"
}
if test "${1}" = "html" -o "${1}" = "pdf"
then
pandoc_html "${1}"
elif test "${1}" = "docx" -o "${1}" = "odt"
then
pandoc_docx "${1}"
elif test "${1}" = "all"
then
pandoc_html pdf && pandoc_docx docx && pandoc_docx odt skip
else
echo "Specify a format (pdf, html, docx)"
exit
fi