sub prepareOutput { my $self = shift; my $node = shift; unless(defined($node)) { warn "No parsable node or tree passed."; return; } # Add the current node tag to the stack $current_tag = $node->tag; unshift(@{$old_tag},$current_tag); # See if we are a frameset if($node->tag eq 'frameset') { $self->[FRAMESET]++; } if(DEBUG) { $self->[OUTPUT] .= $old_parent->[0] if defined($old_parent->[0]); $self->[OUTPUT] .= $old_tag->[0] if defined($old_tag->[0]); } # If we are a child if(defined($node->parent)) { # Store the parent in the parent tag - we do this incase # we meet some text and we don't have the parent call available $current_parent = $node->parent->tag; unshift(@{$old_parent},$current_parent); # Check that the parent allows us to be indented, accomodating # for comments. if( $current_parent eq 'td' && $node->parent->content_list < 1 && $node->tag eq 'a' || $node->tag eq 'img' ) { $self->[OUTPUT] .= '<' . $node->tag; } elsif($self->[TAG]->canIndentChild($current_parent)) { if($node->tag eq '~comment') { $self->[OUTPUT] .= "\t" x $mod; $self->[OUTPUT] .= '\n" : $self->[OUTPUT] .= "\t" x $mod . 'tag . ">\n"; } else { if($self->[TAG]->canIndentChild($old_parent->[0])) { ($node->tag eq '~comment') ? $self->[OUTPUT] .= " -->\n": $self->[OUTPUT] .= 'tag . ">\n"; } else { ($node->tag eq '~comment') ? $self->[OUTPUT] .= " -->": $self->[OUTPUT] .= 'tag . ">"; } } } # Remove our current bits off the stacks and return. $current_parent = shift( @{$old_parent}); $current_tag = shift( @{$old_tag}); }