-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·63 lines (47 loc) · 1.32 KB
/
build.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
rm -rf dist
mkdir -p dist
echo 'build book.epub'
rm -rf build
mkdir -p build
find src -iname "*.md" -exec cp {} build \;
find src -iname "*.png" -exec cp {} build \;
find src -iname "*.svg" -exec cp {} build \;
cp README.md build/0.md
cp title.txt build
cd build
PNG=`find . -iname "*.png"`
for f in $PNG
do
optipng $f
done
SVG=`find . -iname "*.svg"`
cd ..
for f in $SVG
do
filename=$(basename "$f")
filename="${filename%.*}"
node_modules/.bin/svgexport build/$f build/$filename.png 640:
done
cd build
find . -type f -name '*.md' -exec sed -i -r 's/\.svg\w*\)/\.png\)/g' {} \;
FILES=`find . -iname "*.md" | sort`
pandoc -f markdown+header_attributes -t epub3 -S --normalize --epub-chapter-level=4 --toc-dept=4 -o ../dist/book.epub title.txt $FILES
cd ..
echo 'build book-svg.epub'
rm -rf build-svg
mkdir -p build-svg
find src -iname "*.md" -exec cp {} build-svg \;
find src -iname "*.png" -exec cp {} build-svg \;
find src -iname "*.svg" -exec cp {} build-svg \;
cp README.md build-svg/0.md
cp title.txt build-svg
#node_modules/.bin/svgo -f build-svg
cd build-svg
PNG=`find . -iname "*.png"`
for f in $PNG
do
optipng $f
done
FILES=`find . -iname "*.md" | sort`
pandoc -f markdown+header_attributes -t epub3 -S --normalize --epub-chapter-level=4 --toc-dept=4 -o ../dist/book-svg.epub title.txt $FILES