Korean CJKmainfont changed
[gitmagic.git] / makeover
blobf945986363de881273d0b424987d36848e752126
1 #!/bin/bash
3 # Extract table of contents from index.html and delete preface link.
4 BOOKDIR=book-$1
5 TITLE="Git Magic"
6 case $1 in
7 ru)
8 TITLE="Волшебство Git"
9 ;;
10 esac
12 gawk '
13 /<div class="toc">/ {
14 print $0
15 getline
16 print $0
17 print "<li><b>'"$TITLE"'</b></li>"
18 getline
19 while (!match($0, "</div>")) {
20 gsub("pr01.html", "index.html")
21 print $0
22 getline
24 print $0
25 exit
27 ' < $BOOKDIR/index.html > toc.tmp
29 # For every file except the index...
30 for FILE in $BOOKDIR/*.html
32 sed '/<title>/a <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">' -i $FILE
33 if [ $FILE != "$BOOKDIR/index.html" ]
34 then
35 # Prepend "Git Magic - " to titles of all pages.
36 sed '/<title>/ s/<title>/&'"$TITLE"' - /' -i $FILE
37 sed 's/pr01\.html/index.html/g' -i $FILE
38 # Paste ToC into beginning and add div section with class content for CSS.
39 sed '/<body/{n; r toc.tmp
40 a <div class="content">
41 }' -i $FILE
42 sed '/^<\/body/i </div>' -i $FILE
44 done
46 # Originally this link was "My Homepage". Since it appears on translations of
47 # the guide, I changed it to my name so it doesn't have to be translated.
48 sed '/^<\/body/i </div><div class="footer"><a href="/~blynn/">Ben Lynn</a></div>' -i $BOOKDIR/*.html
50 cp $BOOKDIR/pr01.html $BOOKDIR/index.html
51 rm toc.tmp