-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathbuildBook.sh
executable file
·100 lines (75 loc) · 3.17 KB
/
buildBook.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
usage() {
echo "Usage: $0 [-l languageCode]" 1>&2
}
exit_abnormal() {
usage
exit 1
}
langName="en"
while getopts "l:" options; do
case "${options}" in
l)
langName=${OPTARG}
;;
:)
echo "Error: -${OPTARG} requires an argument."
exit_abnormal
;;
*)
exit_abnormal
;;
esac
done
shift $(($OPTIND - 1))
remainingArgs=$@
./tools/commatrademark.sh boo.$langName.idx > trademarks.md
rm -f foo.$langName.* boo.$langName.*
filesToProcess=$(./tools/get_markdown_for_lang.sh -l $langName $(cat frontPages.txt mainPages.txt))
latexFilesToProcess=$(./tools/get_markdown_for_lang.sh -l $langName $(cat frontPages_latex.txt mainPages.txt backPages_latex.txt))
# We allow first person in the preface and second person in the Introduction.
# Elsewhere it is third person only.
ignoreFiles='Introduction|Preface|Acknowledgements'
echo Usages of "you" in the narrative
for file in $filesToProcess
do
if [[ $file =~ $ignoreFiles ]]
then
echo -n .
else
grep you $file | grep --color -v hammer | grep -i --color -v layout || echo -n .
fi
done
scriptPath="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
./tools/clean_gutter.sh -r $scriptPath $filesToProcess
echo
echo Processing foo.$langName.html
pandoc $filesToProcess pandocMetaData.yaml -f markdown+smart --standalone --bibliography bibliography.bib --toc -c style/gitHubStyle.css -o foo.$langName.html
echo Processing boo.$langName.latex
echo Performing pandoc $latexFilesToProcess pandocMetaData.yaml -f markdown+smart --standalone --bibliography bibliography.bib --toc --template=style/styleToCreateIndex.latex -V documentclass=book -o boo.$langName.latex
pandoc $latexFilesToProcess pandocMetaData.yaml -f markdown+smart --standalone --bibliography bibliography.bib --toc --template=style/styleToCreateIndex.latex -V documentclass=book -o boo.$langName.latex
echo Cleaning up csl indent remarks
sed -e '/if(csl-hanging-indent)/{N;d;}' -i.bak boo.$langName.latex
echo Indexing pass 0
pdflatex boo.$langName.latex > boo.$langName.pass.0.log </dev/null
echo Indexing pass 1
pdflatex boo.$langName.latex > boo.$langName.pass.1.log </dev/null
echo Indexing pass 2
pdflatex boo.$langName.latex > boo.$langName.pass.2.log </dev/null
echo "Check for errors"
egrep -n "LaTeX Error:|Error: Unicode character|Fatal error occurred" boo.$langName.pass.*.log
echo Processing foo.$langName.epub
pandoc $filesToProcess pandocMetaData.yaml -f markdown+smart --standalone --bibliography bibliography.bib --toc --css=style/ebook.css -o foo.$langName.epub
echo Processing foo.$langName.docx
pandoc $filesToProcess pandocMetaData.yaml -f markdown+smart --standalone --bibliography bibliography.bib --reference-doc=style/referenceWordDocumentTemplate.docx -o foo.$langName.docx
echo Constructing github pages
mkdir -p docs/$langName
cp foo.$langName.html docs/$langName/index.html
git add docs/$langName/index.html
rm -rf docs/$langName/screenshots docs/$langName/style
cp -pr screenshots docs/$langName/screenshots
cp -pr style docs/$langName/style
echo Checking in github pages changes
git add docs/$langName/screenshots docs/$langName/style
git commit -m"update published $langName book on github pages"
git push