]> Pileus Git - ~andy/aweather-web/blob - toc.awk
Fix typo
[~andy/aweather-web] / toc.awk
1 // {
2         if (match($0, /<h[0-9] id="([^"]*)">([0-9.]* *)([^<]*)<\/h[0-9]>/, arr)) {
3                 id   = arr[1];
4                 num  = arr[2];
5                 txt  = arr[3];
6                 toc  = toc  "\n" "<li>" num "<a href=\"#" id "\">" txt "</a></li>"
7                 body = body "\n" "<a id=\"" id "\"></a>"
8         }
9         body = body "\n" $0
10 }
11
12 END {
13         print "<h2>Table of Contents</h2>";
14         print "<ul style=\"list-style:none;\">" toc "</ul>";
15         print body;
16 }