3 # extract table of contents from index.html
8 getline #TODO: check this is the <ul> line
10 print "<li><a href=\".\">Git Magic</a></li>"
12 while (!match($0, "</div>")) {
19 ' < $BOOKDIR/index.html
> toc.tmp
21 # for every chapter...
22 for FILE
in $BOOKDIR/*.html
24 if [ $FILE != "$BOOKDIR/index.html" ]
26 # add " - Git Magic" to titles of all pages
27 sed '/<\/title>/ s/<\/title>/ - Git Magic&/' -i $FILE
28 # paste ToC into beginning
29 # and add div section with class content for CSS
30 sed '/<body/{n; r toc.tmp
31 a <div class="content">
33 sed '/^<\/body/i </div>' -i $FILE
37 sed '/^<\/body/i </div><div class="footer"><a href="/~blynn/">My Homepage</a></div>' -i $BOOKDIR/*.html
39 # extract shell of index.html
40 # then insert ToC and preface
46 if (match($0, "<div")) i++;
47 else if (match($0, "</div")) {
55 ' < $BOOKDIR/index.html |
sed '/<body/{n; r toc.tmp
56 a <div class="content">
60 mv tmp.tmp
$BOOKDIR/index.html