#!/bin/sh
# Filter for sgml2html
# afters2h *.html
for f in $*; do
dir=$(dirname $f)
file=$(basename $f .html)
tt=$dir/$file
perl -w -e '
use strict;
my($mode) = 0;
while (<>) {
if ($mode == 0 && /
(.*)<\/title>/) {
print "[% title = \"$1\" %]\n";
}
if (//) {
$mode = 1;
next;
}
next if ($mode == 0);
if (/<\/?h(\d+)>/i) {
my($h) = $1;
$h++;
s///;
s/<\/h(\d+)>/<\/h$h>/;
}
if (/<\/body>/) {
last;
}
s/\@/\@/go;
print;
}' < $f > $tt.tt2
rm $f
done