Skip to content

Commit e9b3127

Browse files
committed
pdf.sh: Add script.
1 parent 82922a3 commit e9b3127

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pdf.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
if [ ! -d pdf ]; then
4+
mkdir pdf
5+
fi
6+
7+
pandoc -f markdown -t pdf src/SUMMARY.md -o pdf/1.pdf
8+
9+
I=2
10+
for FILE in $(awk -e 'match($0, /\([^)]+\)$/) { print substr($0, RSTART+1, RLENGTH-2) }' \
11+
src/SUMMARY.md); do
12+
echo "Converting $FILE ..."
13+
pandoc -f markdown -t pdf src/$FILE -o pdf/$I.pdf
14+
I=$(($I + 1))
15+
done
16+
17+
# Create list of sections in numeric, rather than lexicographic, order.
18+
# For portability, don't use seq(1) or jot(1) here.
19+
LIMIT=$I
20+
I=1
21+
SECTIONS=
22+
while [ "$I" -lt "$LIMIT" ]; do
23+
# Temporary special-casing.
24+
if [ "$I" -ne 13 -a "$I" -ne 34 ]; then
25+
SECTIONS="$SECTIONS $I.pdf"
26+
fi
27+
I=$(($I + 1))
28+
done
29+
30+
echo -n "Compiling Handbook ... "
31+
if [ -f handbook.pdf ]; then
32+
rm handbook.pdf
33+
fi
34+
cd pdf
35+
pdfunite $SECTIONS ../handbook.pdf
36+
echo "done"
37+
38+
cd ..
39+
rm -rf pdf

0 commit comments

Comments
 (0)