#!/usr/local/bin/perl
# austenize.pl:  convert a chapter of ASCII Jane Austen novel to HTML
# Usage:  austen.pl <chapter#.txt >chapter#.html
# Amen Zwa, TriloBYTE, 03/08/1996 f.

# print header
print "<HTML>\n<HEAD>\n<TITLE>Jane Austen Novel</TITLE>\n</HEAD>\n";
print "<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"\n";
print "LINK=\"#00007F\" VLINK=\"#7030B0\">\n";

# convert chapter
while (<>) {
    s/>//g;
    s/_(.*)_/\<EM\>\1\<\/EM\>/g;	# emphasis
    s/^\n$/\<P\>\n/;			# paragraph
    if (/^TITLE/) {			# title
	chop;
	s/<TITLE//g;
	print "<CENTER><H1>", $_, "</H1></CENTER>\n";
    } elsif (/^SUBTITLE/) {		# subtitle
	chop;
	s/<SUBTITLE//g;
	print "<CENTER><STRONG>", $_, "</STRONG></CENTER>\n";
    } elsif (/^AUTHOR/) {		# author
	chop;
	s/<AUTHOR//g;
	print "<CENTER>", $_, "</CENTER>\n";
    } elsif (/^DATE/) {		# date of publication
	chop;
	s/<DATE//g;
	print "<CENTER>", $_, "</CENTER>\n";
    } elsif (/^VOLUME/) {		# volume name
	chop;
	s/<//g;
	print "<H2>", $_, "</H2>\n";
    } elsif (/^[Cc][Hh][Aa][Pp][Tt][Ee][Rr] [A-Z0-9]/) {	# chapter name
	chop;
	s/<//g;
	print "<HR>\n<H3>", $_, "</H3>\n";
    } elsif (/__/) {			# end-of-chapter
	# skip
    } else {
	print;
    }
}

# print footer
print "<P>\n<HR>\n<ADDRESS>\n";
print "<A HREF=\"http://uts.cc.utexas.edu/~churchh/janeinfo.html#janetoc\">
Jane Austen</A>\n";
print "</ADDRESS>\n";
print "(the author of ";
print "<A HREF=\"http://uts.cc.utexas.edu/~churchh/pridprej.html\">
<EM>Pride and Prejudice</EM></A>)\n";
print "</BODY>\n</HTML>\n";
