The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
package Text::Trac::Dl;

use strict;
use base qw(Text::Trac::BlockNode);

our $VERSION = '0.16';

sub init {
    my $self = shift;
    $self->pattern(qr/^\s+(.*)::$/xms);
}

sub parse {
    my ( $self, $l ) = @_;
    my $c = $self->{context};
    my $pattern = $self->pattern;

    if( !@{$c->in_block_of} or $c->in_block_of->[-1] ne 'dl' ){
        $c->htmllines('<dl>');
        push @{$c->in_block_of}, 'dl';
    }

    $c->unshiftline;
    while($c->hasnext){
        last if( $c->nextline  =~ /^$/ );
        my $l = $c->shiftline;

        if( $l =~ /$pattern/ ){
            if ( $c->in_block_of->[-1] eq 'dd' ){
                $l = "</dd>\n<dt>$1</dt>";
                pop @{$c->in_block_of};
            }
            else {
                $l = "<dt>$1</dt>";
            }
        }
        else {
            $l =~ s/^\s+//g;
            if( $c->in_block_of->[-1] ne 'dd' ){
                $l = "<dd>\n$l";
                push @{$c->in_block_of}, 'dd';
            }
        }
        $c->htmllines($l);
    }

    if ( $c->in_block_of->[-1] eq 'dd' ){
                $c->htmllines('</dd>');
                pop @{$c->in_block_of};
    }

    pop @{$c->in_block_of};
    $c->htmllines('</dl>');

    return;
}

1;