use strict;

# ==============================================================================
# skip head, some texts, flatten file and body, references, navigation
sub DTDx
{
    my ($node, $dtd) = @_;
    $_ = $node->{'path'};
    my $class = lc( $node->{'attr'}{'class'} || '' );

    my $prev = $node->{'parent'}{'content'}[-1] || undef;
    my $next = $node->{'parent'}{'precontent'}[0] || undef;

    ( m</(TEXT(_S)?|tt|i|b|ref_\w+|li|dd|dt|br)/$> ||
      m</div/$> && $node->{'attr'}{'class'} eq 'programlisting' )
      && $node->{'content'} !~ /^\s*$/ && do
    {
        if( $prev )
        {
            if( $prev->{'tag'} =~ /^(TEXT(_S)?|tt|i|b|p|ref_\w+|li|dd|dt|br)$/||
                $prev->{'tag'} eq 'div' &&
                $prev->{'attr'}{'class'} eq 'programlisting')
            {
                return $node;
            }
            
            if( $prev )
            {
                print $prev->Tx( "%f:%p\n" );
            }
            print $node->Tx( "  %f:%p\n" );
            if( $next )
            {
                print $next->Tx( "%f:%p\n" );
            }
            print "\n\n";
        }
    };
    
    return $node->Proc( $dtd );
}
    
1;
