-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbooks.sh
More file actions
executable file
·26 lines (17 loc) · 630 Bytes
/
Copy pathbooks.sh
File metadata and controls
executable file
·26 lines (17 loc) · 630 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/bash -ex
mkdir -p _site/books
for full_book in books/*
do
if [ -d "$full_book" ]; then
book=$(basename "$full_book")
echo Book $book
cd books/$book
mdbook build
perl -i -p -e 's{href="index.html"}{href="."}g' book/toc.js
perl -i -p -e 's{(href="[a-zA-Z0-9.][^"]+)\.html"}{$1"}g' book/toc.js
find book/ -name *.html | xargs perl -i -p -e 's{href="index.html"}{href="."}g'
find book/ -name *.html | xargs perl -i -p -e 's{(href="[a-zA-Z0-9.][^"]+)\.html"}{$1"}g'
cd ../..
mv books/${book}/book _site/$book
fi
done