-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlinux-pdf.sh
44 lines (42 loc) · 1.46 KB
/
linux-pdf.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
#!/bin/bash
# That tells Linux to use a Bourne shell interpreter.
# Don't echo these commands:
set +v
# Ask user which folder to process
echo -n "Which book folder are we processing? "
read book
echo "Okay, let's process $book..."
# Ask the user to add any extra Jekyll config files, e.g. _config.pdf-ebook.yml
echo -n "Any extra config files? (full filename, comma-separated, no spaces) "
read config
echo "Rightio, we'll add $config to the configuration"
# We're going to let users run this over and over by pressing enter
while [ "$repeat" = "" ]
do
# let the user know we're on it!
echo "Generating HTML..."
# ...and run Jekyll to build new HTML
bundle exec jekyll build --config="_config.yml,$config"
# Navigate into the book's folder in _site output
cd _site/$book
# Let the user know we're now going to make the PDF
echo Creating PDF...
# Run prince, showing progress (-v), printing the docs in file-list
# and saving the resulting PDF to the _output folder
prince -v -l file-list -o ../../_output/$book.pdf
# Navigate back to where we began.
cd ../..
# Tell the user we're done
echo Done!
# Navigate to the _output folder...
cd _output
# and open the PDF we just created
# (for OSX, this will need to be open, not xdg-open)
xdg-open $book.pdf
# Navigate back to where we began.
cd ../
# Ask the user if they want to refresh the PDF by running jekyll b and prince again
repeat=""
echo "Enter to run again, or any other key and enter to stop."
read repeat
done