#!/usr/bin/perl
#
# Copyright (C) 1997-98 Mark Boyns <boyns@sdsu.edu>
#
# This file is part of Muffin.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

while (<>)
{
    $line++;
    if ($line == 1)
    {
	chop;
	print "<head>\n";
	print "<title>$_</title>\n";
	print "</head>\n";
	print "<body>\n";
	print "<pre>\n";
	print "<h1>$_</h1>\n";
	next;
    }

    s/\</\&lt;/g;
    s/\>/\&gt;/g;

    if (/^\* /)
    {
	if (!$inlist)
	{
	    print "<ul>";
	    $inlist = 1;
	}
	else
	{
	    print "\n";
	}
	print "<li>";
	s/^\* //g;
    }
    elsif ($inlist && /^[^\s]/)
    {
	print "</ul>\n";
	$inlist = 0;
    }
    #elsif ($inlist)
    #{
#	s/^\s+//g;
#    }
    
    if (/^([A-Za-z0-9]+):$/)
    {
	print "<h2>$1</h2>\n";
    }
    elsif (/^(\s+)([A-Za-z]+):$/)
    {
	print "$1<strong>$2</strong>\n";
    }
    elsif (/(See the )([A-Za-z_\-\.]+)( file .*)/)
    {
	print "$1<a href=\"$2.html\">$2</a>$3\n";
    }
    else
    {
	s#(muffin.filter.)([A-Za-z]+)#<a href="/doc/filter/$2.html">$1$2</a>: #;
	s#([-a-z.0-9]+@[-a-z.0-9]+)#<a href="mailto:$1">$1</a>#i;
	s#(http://[^/]*/*[^\s]*)#<a href="$1">$1</a>#i;
	s#\*(\w+)\*#<strong>$1</strong>#g;
	print;
    }
}
print "</ul>\n" if $inlist;
print "</pre>\n";
print "<hr>\n";
print "<p align=center><a href=\"http://muffin.doit.org/\"><img border=0 src=\"http://muffin.doit.org/images/mufficon.gif\" alt=\"Muffin\"></a></p>\n";
print "</body>\n";
