1#!/bin/nawk
2# cleans up any leading crap before <TITLE> line in stream from tk2html
3
4/^<TITLE>/ { go = 1 }
5
6/^<table>*/ {
7        getline ln
8        numf = split (ln, spln)
9
10        if ( ln !~ "Name: *" )
11        {
12            ind = 0
13            inc = 4
14            print "<table cellpadding=5>"
15
16            while ( ln !~ "^</table>" )
17            {
18                for (i = 1; i <= numf; i++)
19                {
20                    tablns[ind] = spln[i]
21                    ind++
22                }
23                getline ln
24                numf = split (ln, spln)
25            }
26
27            for (i = 0; i < inc; i++)
28                {
29                    print "<td valign=top>"
30                    for (j = i; j < ind; j += inc)
31                        print tablns[j] "<br>"
32                    print "</td>"
33                }
34            
35            print "</table>"
36        }
37
38        else
39        {
40            print "<pre>"
41            while ( ln !~ "^</table>" )
42            {
43                print ln
44                getline ln
45            }
46            print "</pre>"
47        }
48        
49        next
50    }
51
52go == 1 { print $0 }
53
54