shlomif / perl-XML-SemanticDiff

The XML-SemanticDiff CPAN distribution for semantic (= non-ordered and probably not what you want) comparison of two XML docs
https://metacpan.org/release/XML-SemanticDiff
Other
2 stars 5 forks source link

Request: make whitespace handling configurable #9

Closed tplass closed 2 years ago

tplass commented 5 years ago

Copy of RT ticket:

Consider these 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);

}
shlomif commented 5 years ago

Please see the discussion on https://github.com/shlomif/perl-XML-SemanticDiff/issues/3 - I no longer maintain XML-SD.

tplass commented 5 years ago

Well, the module brought me here:

C:/usr/local/perl5/cpan/build/XML-SemanticDiff-1.0007-wsCwGT> grep -c github.com/shlomif lib/XML/SemanticDiff.pm 
3

Maybe PERIGRIN should fix those? Is he notified of GitHub issues?

shlomif commented 2 years ago

Closing.