#!/usr/bin/perl

#    The MySQL General Purpose Stored Routines Library
#    Copyright (C) 2005 Giuseppe Maxia, Stardata s.r.l.
#    Contacts: http://www.stardata.it/contatti_en.html
#
#    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA


use strict;
use warnings;
use Data::Dumper;

my $seen = 0;

while (<>)
{
    next if /^[fp]syntax/;
    s/=>/=&gt;/g;
    if (/^\*\*\*+/)
    {
        print  qq(</pre>\n) if $seen++;
        print qq(<hr>\n);
    }
    elsif (/\s+ \*\* \s+ (function|procedure) \s+ (\w+)\.(\w+) /x)
    {
        printf qq(<h3><a name="#%s">%s %s</a></h3>\n), $3, $1, $3;
        print  qq(<pre>\n);
    }
    else
    {
        print;
    }
}
print  qq(</pre>\n);
