#!/usr/bin/perl -w
require 5;
use strict;
# Read a textish file and output HTMLish stuff.
# Terribly kludgy at the moment.
# $Id: metext,v 1.2 1998/03/22 01:28:41 kragen Exp $

my $betweenparas = 0;

sub hdr1 { <<eoh;
<html><head><title>$_[0]</title></head><body
bgcolor="#ffffff" text="#000000" link="#0000ff" alink="#ff0000"
vlink="#aa00aa">
<h1> $_[0] </h1>\n 
eoh
}
sub hdr2 { "<h2> $_[0] </h2>\n"; }

my $lastline = "";
line: while (<>) {
	s/(^|\W)\*(\w|$)/$1<em>$2/g;
	s/(^|\w)\*(\W|$)/$1<\/em>$2/g;
	s#<URL:(.*?)>#<a href="$1">$1</a>#g;
	if (/^[\s-]*-[\s-]*$/) {
		print hdr2($lastline);
		$lastline = "";
		$betweenparas = 1;
		next line;
	} elsif (/^[\s=]*=[\s=]*$/) {
		print hdr1($lastline);
		$lastline = "";
		$betweenparas = 1;
		next line;
	} elsif (/^\s*-\s+(.*)$/) {
		print $lastline;
		$lastline = "<li> $1\n";
		$betweenparas = 0;
		next line;
	} elsif (/^\s*$/) {
		if (not $betweenparas) {
			print $lastline;
			$lastline = "";
			print "<p>\n";
			$betweenparas = 1;
		}
	} else {
		print $lastline;
		$lastline = $_;
		$betweenparas = 0;
		next line;
	}
}

print $lastline;

print <<eof;
</body></html>
eof

