Skip to content

Commit 2b46f41

Browse files
committed
pdf.sh: Add script.
1 parent 6a08cde commit 2b46f41

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ dependencies:
1414
- `mdBook`
1515
- `fd`
1616
- `pandoc`
17+
18+
The [pdf.sh](./pdf.sh) script builds a PDF version of the Handbook. It requires
19+
the following dependencies:
20+
21+
- `texlive`
22+
- `pandoc`
23+
- `poppler`

pdf.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
SECTIONS="$SECTIONS $I.pdf"
24+
I=$(($I + 1))
25+
done
26+
27+
echo -n "Compiling Handbook ... "
28+
if [ -f handbook.pdf ]; then
29+
rm handbook.pdf
30+
fi
31+
cd pdf
32+
pdfunite $SECTIONS ../handbook.pdf
33+
echo "done"
34+
35+
cd ..
36+
rm -rf pdf

0 commit comments

Comments
 (0)