package Text::WordDiff::HTMLTwoLines;
use strict;
use HTML::Entities qw(encode_entities);
use vars qw($VERSION @ISA);
$VERSION = '0.08';
@ISA = qw(Text::WordDiff::Base);
sub file_header {
my $self = shift;
my $fn1 = $self->filename_a;
my $fn2 = $self->filename_b;
if (defined $fn1 && defined $fn2)
{ my $p1 = $self->filename_prefix_a;
my $t1 = $self->mtime_a;
my $p2 = $self->filename_prefix_b;
my $t2 = $self->mtime_b;
$self->{__str1} = '
';
$self->{__str2} = '
';
}
else
{ $self->{__str1} = $self->{__str2} = '
';
}
return '';
}
sub hunk_header {
my $self = shift;
$self->{__str1} .= '';
$self->{__str2} .= '';
return '';
}
sub hunk_footer {
my $self = shift;
$self->{__str1} .= '';
$self->{__str2} .= '';
return '';
}
sub file_footer {
my $self = shift;
return $self->{__str1} . "
\n" . $self->{__str2} . "
\n";
}
sub same_items {
my $self = shift;
$self->{__str1} .= encode_entities( join '', @_ );
$self->{__str2} .= encode_entities( join '', @_ );
return '';
}
sub delete_items {
my $self = shift;
$self->{__str1} .= '
' . encode_entities( join '', @_ ) . '';
return '';
}
sub insert_items {
my $self = shift;
$self->{__str2} .= '
' . encode_entities( join '', @_ ) . '';
return '';
}
1;
__END__
=head1 Name
Text::WordDiff::HTMLTwoLines - XHTML formatting for Text::WordDiff with content on two lines
=head1 Synopsis
use Text::WordDiff;
my $diff = word_diff 'file1.txt', 'file2.txt'; { STYLE => 'HTMLTwoLines' };
my $diff = word_diff \$string1, \$string2, { STYLE => 'HTMLTwoLines' };
my $diff = word_diff \*FH1, \*FH2, { STYLE => 'HTMLTwoLines' };
my $diff = word_diff \&reader1, \&reader2, { STYLE => 'HTMLTwoLines' };
my $diff = word_diff \@records1, \@records2, { STYLE => 'HTMLTwoLines' };
# May also mix input types:
my $diff = word_diff \@records1, 'file_B.txt', { STYLE => 'HTMLTwoLines' };
=head1 Description
This class subclasses Text::WordDiff::Base to provide a XHTML formatting for
Text::WordDiff. See L
for usage details. This
class should never be used directly.
Text::WordDiff::HTMLTwoLines formats word diffs for viewing in a Web browser.
The output is similar to that produced by
L but the two lines (or files,
records, etc.) are shown separately, with deleted items highlighted in the
first line and inserted items highlighted in the second. HTMLTwoLines puts a
span tag around each word or set of words in the diff.
The diff content is highlighted as follows:
=over
=item * C<< >>
The inputs to C are each contained in a div element of class
"file". All the following results are subsumed by these elements.
=over
=item * C<<