forked from electricbookworks/electric-book-workflow
/
win-print-pdf.bat
37 lines (37 loc) · 1.51 KB
/
win-print-pdf.bat
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
:: Don't show these commands to the user
@ECHO off
:: Set the title of the window
TITLE Making new PDF...
:: Ask user which folder to process
SET /p book=Which book folder are we processing?
:: Ask the user to add any extra Jekyll config files, e.g. _config.images.print-pdf.yml
SET /p config=Any extra config files? (in addition to _config.print-pdf.yml; full filename, comma-separated, no spaces)
:: Loop back to this point to refresh the build and PDF
:refresh
:: let the user know we're on it!
ECHO Generating HTML...
:: ...and run Jekyll to build new HTML
CALL bundle exec jekyll build --config="_config.yml,_config.print-pdf.yml,%config%"
:: Navigate into the book's folder in _html output
CD _html\%book%\text
:: 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
:: (For some reason this has to be run with CALL)
CALL prince -v -l file-list -o ..\..\..\_output\%book%.pdf
:: Navigate back to where we began.
CD ..\..\..
:: Tell the user we're done
ECHO Done! Opening PDF...
:: Navigate to the _output folder...
CD _output
:: and open the PDF we just created
:: (`start` so the PDF app opens as a separate process, doesn't hold up this script)
start %book%.pdf
:: Navigate back to where we began.
CD ..\
:: Let the user easily refresh the PDF by running jekyll b and prince again
SET repeat=
SET /p repeat=Enter to run again, or any other key and enter to stop.
IF "%repeat%"=="" GOTO refresh