1package Text::Trac::Dl; 2 3use strict; 4use warnings; 5use base qw(Text::Trac::BlockNode); 6 7our $VERSION = '0.24'; 8 9sub init { 10 my $self = shift; 11 $self->pattern(qr/^\s+(.*)::$/xms); 12} 13 14sub parse { 15 my ( $self, $l ) = @_; 16 my $c = $self->{context}; 17 my $pattern = $self->pattern; 18 19 if ( !@{ $c->in_block_of } or $c->in_block_of->[-1] ne 'dl' ) { 20 $c->htmllines('<dl>'); 21 push @{ $c->in_block_of }, 'dl'; 22 } 23 24 $c->unshiftline; 25 while ( $c->hasnext ) { 26 last if ( $c->nextline =~ /^$/ ); 27 my $l = $c->shiftline; 28 29 if ( $l =~ /$pattern/ ) { 30 if ( $c->in_block_of->[-1] eq 'dd' ) { 31 $l = "</dd>\n<dt>$1</dt>"; 32 pop @{ $c->in_block_of }; 33 } 34 else { 35 $l = "<dt>$1</dt>"; 36 } 37 } 38 else { 39 $l =~ s/^\s+//g; 40 if ( $c->in_block_of->[-1] ne 'dd' ) { 41 $l = "<dd>\n$l"; 42 push @{ $c->in_block_of }, 'dd'; 43 } 44 } 45 $c->htmllines($l); 46 } 47 48 if ( $c->in_block_of->[-1] eq 'dd' ) { 49 $c->htmllines('</dd>'); 50 pop @{ $c->in_block_of }; 51 } 52 53 pop @{ $c->in_block_of }; 54 $c->htmllines('</dl>'); 55 56 return; 57} 58 591; 60