--- /dev/null
+#! /usr/bin/awk -f
+
+BEGIN { n = 0; opts = 0; sep = 0; }
+
+/^\.\\\"\* ([0-9]+) (.*)$/ {
+ n = $2;
+ name = $3;
+ for (i = 4; i <= NF; i++) name = name " " $i;
+ head[n] = name;
+}
+/^\.\\\"\+opts$/ { opts = 1; lines[n] = lines[n] "\\h'2n'Options:\n.RS\n"; }
+/^\.\\\"\-opts$/ { opts = 0; lines[n] = lines[n] ".RE\n"; }
+/^\.\\\"\+sep$/ { sep = 1; }
+/^\.\\\"\-sep$/ { sep = 0; }
+/^\.\\\"\-opts$/ { opts = 0; lines[n] = lines[n] ".RE\n"; }
+/^\.SP/ { print; getline; lines[n] = lines[n] $0 "\n"; }
+/^\.TP/ { if (opts) { print; getline; lines[n] = lines[n] $0 "\n"; } }
+/^\.SS/ { if (sep) lines[n] = lines[n] ".PP\n"; }
+
+{ print; }
+
+/^\.\\\"= summary/ {
+ for (i = 0; i < 100; i++) {
+ if (!(i in head)) continue;
+ print ".SS \"" head[i] "\"";
+ print ".nf";
+ print lines[i] ".fi";
+ }
+}