use strict;
use FileHandle;

package MParser;

sub new
{
    my $class = shift;
    $class = ref($class) || $class;

    my $this = { 'classes' => $_[1],
                 'fh' => $_[0],
                 'row' => ''};

    bless($this, $class);
    return $this;
}


sub HilitHelp
{
    my $this = shift;
    my $Row = $this->{ 'row' } || $this->{ 'fh' }->getline();

    while( $Row )
    {
        chomp $Row;
        $Row !~ /^\s*\%/ && last;

        print "<span class=help>";
        if( $Row =~ /^(\s*\%\s*)(\w+:)\s*$/ )
        {
            $Row = $2;
            PrintOther( $1 );
            print "<span class=help_field>";
            PrintOther( $Row );
            print "</span>";
        }
        else
        {
            PrintOther( $Row );
        }
        print "</span><br>\n";
        $Row = $this->{ 'fh' }->getline();
    }

    $this->{ 'row' } = $Row;
}

sub PrintOther
{ 
    my $tx = $_[0];
    $tx =~ s/</\&lt;/g;
    $tx =~ s/>/\&gt;/g;

    $tx =~ s/ /\&nbsp;/g;
    $tx =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
    print $tx;
}

1;
