-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.bat
executable file
·72 lines (56 loc) · 1.92 KB
/
build.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
@echo off
setlocal
set JOBNAME=lisp
set MAIN_FILE=!main.tex
set FIGURES_FILE=!figures_only.tex
set INDEX_FILES=lisp-eng.idx lisp.idx
set LATEX_KEYS=-job-name=%JOBNAME% -interaction=batchmode
set ROOT=%CD%
if "%1"=="pdf" goto :prepare_pdf
if "%1"=="" goto :prepare_pdf
if "%1"=="epub" goto :prepare_epub
echo Usage: %0 [epub ^| pdf]
exit /b 1
:prepare_pdf
echo == Preparing PDF ==
cd %ROOT%\book-src
git 2> NUL
if not %ERRORLEVEL%==9009 (
git log -1 --format='\newcommand{\GitCommit}{%H}
\newcommand{\GitCommitDate}{%ci}' > git-version.tex
)
pdflatex %LATEX_KEYS% %MAIN_FILE%
python %ROOT%\makeindex.py %INDEX_FILES% > %JOBNAME%.ind
pdflatex %LATEX_KEYS% %MAIN_FILE%
python %ROOT%\makeindex.py %INDEX_FILES% > %JOBNAME%.ind
pdflatex %LATEX_KEYS% %MAIN_FILE%
echo == Done ==
move %JOBNAME%.pdf %ROOT%
del /q *.aux *.idx *.ind *.log *.out *.toc git-version.tex
goto:eof
:prepare_epub
mkdir %ROOT%\epub\OEBPS\images
echo == Rendering images ==
cd %ROOT%\book-src
pdflatex %LATEX_KEYS% %FIGURES_FILE%
pdflatex %LATEX_KEYS% %FIGURES_FILE%
move %JOBNAME%.pdf %ROOT%\epub\OEBPS\images
del *.aux *.log *.out
echo == Converting to PNG ==
cd %ROOT%\epub\OEBPS\images
convert -monitor -density 300 %JOBNAME%.pdf -trim -quality 90 png%%02d.png
del %JOBNAME%.pdf
echo == Packaging EPUB ==
cd %ROOT%\epub
for /f %%a in ('dir /B %ROOT%\epub\fontconfig') do (
echo - %%~na
copy /y %ROOT%\epub\fontconfig\%%a %ROOT%\epub\OEBPS\zz_fontsize.css
zip --quiet --recurse-paths --compression-method deflate ^
--unicode UTF8 %JOBNAME%-%%~na.epub mimetype META-INF OEBPS
)
echo == Done ==
move *.epub %ROOT%
del /q %ROOT%\epub\OEBPS\images
del /q %ROOT%\epub\OEBPS\zz_fontsize.css
rmdir %ROOT%\epub\OEBPS\images
goto:eof