3 # extract table of contents from index.html
4 # and delete preface link
9 getline #TODO: check this is the <ul> line
11 print "<li><a href=\".\">Git Magic</a></li>"
13 while (!match($0, "</div>")) {
14 if (match($0, "<li><span class=\"preface\"")) {
15 while (!match($0, "</span>")) {
26 ' < $BOOKDIR/index.html
> toc.tmp
28 # for every file except the index...
29 for FILE
in $BOOKDIR/*.html
31 if [ $FILE != "$BOOKDIR/index.html" ]
33 # add "Git Magic - " to titles of all pages
34 sed '/<title>/ s/<title>/&Git Magic - /' -i $FILE
35 sed 's/pr01\.html/index.html/g' -i $FILE
36 # paste ToC into beginning
37 # and add div section with class content for CSS
38 sed '/<body/{n; r toc.tmp
39 a <div class="content">
41 sed '/^<\/body/i </div>' -i $FILE
45 sed '/^<\/body/i </div><div class="footer"><a href="/~blynn/">My Homepage</a></div>' -i $BOOKDIR/*.html
47 mv $BOOKDIR/pr01.html
$BOOKDIR/index.html