1Text::Diff::HTML(3)   User Contributed Perl Documentation  Text::Diff::HTML(3)
2
3
4

Name

6       Text::Diff::HTML - XHTML format for Text::Diff::Unified
7

Synopsis

9           use Text::Diff;
10
11           my $diff = diff "file1.txt", "file2.txt", { STYLE => 'Text::Diff::HTML' };
12           my $diff = diff \$string1,   \$string2,   { STYLE => 'Text::Diff::HTML' };
13           my $diff = diff \*FH1,       \*FH2,       { STYLE => 'Text::Diff::HTML' };
14           my $diff = diff \&reader1,   \&reader2,   { STYLE => 'Text::Diff::HTML' };
15           my $diff = diff \@records1,  \@records2,  { STYLE => 'Text::Diff::HTML' };
16           my $diff = diff \@records1,  "file.txt",  { STYLE => 'Text::Diff::HTML' };
17

Description

19       This class subclasses Text::Diff::Unified, a formatting class provided
20       by the Text::Diff module, to add XHTML markup to the unified diff
21       format. For details on the interface of the "diff()" function, see the
22       Text::Diff documentation.
23
24       In the XHTML formatted by this module, the contents of the diff
25       returned by "diff()" are wrapped in a "<div>" element, as is each hunk
26       of the diff.  Within each hunk, all content is properly HTML encoded
27       using HTML::Entities, and the various sections of the diff are marked
28       up with the appropriate XHTML elements. The elements used are as
29       follows:
30
31       ·   "<div class="file">"
32
33           This element contains the entire contents of the diff "file"
34           returned by "diff()". All of the following elements are subsumed by
35           this one.
36
37           ·   "<span class="fileheader">"
38
39               The header section for the files being "diff"ed, usually
40               something like:
41
42                 --- in.txt    Thu Sep  1 12:51:03 2005
43                 +++ out.txt   Thu Sep  1 12:52:12 2005
44
45               This element immediately follows the opening "file" "<div>"
46               element.
47
48           ·   "<div class="hunk">"
49
50               This element contains a single diff "hunk". Each hunk may
51               contain the following elements:
52
53               ·   "<span class="hunkheader">"
54
55                   Header for a diff hunk. The hunk header is usually
56                   something like:
57
58                     @@ -1,5 +1,7 @@
59
60                   This element immediately follows the opening "hunk" "<div>"
61                   element.
62
63               ·   "<span class="ctx">"
64
65                   Context around the important part of a "diff" hunk. These
66                   are contents that have not changed between the files being
67                   "diff"ed.
68
69               ·   "<ins>"
70
71                   Inserted content, each line starting with "+".
72
73               ·   "<del>"
74
75                   Deleted content, each line starting with "-".
76
77               ·   "<span class="hunkfooter">"
78
79                   The footer section of a hunk; contains no contents.
80
81           ·   "<span class="filefooter">"
82
83               The footer section of a file; contains no contents.
84
85       You may do whatever you like with these elements and classes; I highly
86       recommend that you style them using CSS. You'll find an example CSS
87       file in the eg directory in the Text-Diff-HTML distribution. You will
88       also likely want to wrap the output of your diff in its own element (a
89       "<div>" will do) styled with "white-space: pre".
90

See Also

92       Text::Diff
93       Algorithm::Diff
94

Support

96       This module is stored in an open GitHub repository
97       <http://github.com/theory/text-diff-html/>. Feel free to fork and
98       contribute!
99
100       Please file bug reports via GitHub Issues
101       <http://github.com/theory/text-diff-html/issues/> or by sending mail to
102       bug-Text-Diff-HTML@rt.cpan.org <mailto:bug-Text-Diff-HTML@rt.cpan.org>.
103

Author

105       David E. Wheeler <david@justatheory.com>
106
107       Currently maintained by the developers of The Perl Shop <tps@cpan.org>.
108
110       Copyright (c) 2005-2011 David E. Wheeler. Some Rights Reserved.
111
112       This module is free software; you can redistribute it and/or modify it
113       under the same terms as Perl itself.
114
115
116
117perl v5.30.0                      2019-07-26               Text::Diff::HTML(3)
Impressum