use strict; use HTML::TokeParser; use CGI qw( blockquote ); my $string = join '', ; my $string_ref = \$string; my $p = HTML::TokeParser->new( $string_ref ); my $html; my $last_end_tag; while ( my $token = $p->get_token ) { if ( $token->[0] =~ /[TCD]/ ) { $html .= $token->[1]; } elsif ( $token->[0] eq 'S' ) { if ( $token->[1] eq 'p' and $last_end_tag eq 'h4' ) { $html .= blockquote( $token->[2], $p->get_text('/p') ); $p->get_token(); # toss the

$last_end_tag = 'blockquote'; } else { $html .= $token->[-1]; } } elsif ( $token->[0] eq 'E' ) { # if it's a new blockquote, it's closed already $html .= $token->[-1] unless $token->[1] eq '/p' and $last_end_tag eq 'h4'; $last_end_tag = $token->[1]; } } print $html; __END__

Stand alone p, or, aw, skip it.

This is an h4

A first paragraph.

A follower.

Big finish. Or Finnish?