Subject: | Request: make whitespace handling configureable |
Consider these two cases involving significant whitespace in mixed content:
OLD: <p>Space in mixed content before<i>inline element</i>and after.</p>
NEW: <p>Space in mixed content before <i>inline element</i> and after.</p>
Clearly, whitespace makes a difference. Currently, this difference isn't detected as whitespace is folded by default.
I suggest making whitespace handling subject to an optional parameter ("foldwhitespace") and additionally assume the default to be "off":
sub Text {
my $self = shift;
my $expat = shift;
my $element = $expat->current_element;
my $char = $_;
if($self->opts()->{foldwhitespace}) {
$char =~ s/^\s*//;
$char =~ s/\s*$//;
$char =~ s/\s+/ /g;
}
# We should add any character that isn't undef, so check
# for defined here instead of checking if the value is true
$self->char_accumulator()->{$element} .= $char if defined($char);
}