1Text::Diff::HTML(3) User Contributed Perl Documentation Text::Diff::HTML(3)
2
3
4
6 Text::Diff::HTML - XHTML format for Text::Diff::Unified
7
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
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 a "<pre>" element.
89
91 Text::Diff
92 Algorithm::Diff
93
95 This module is stored in an open repository at the following address:
96
97 https://svn.kineticode.com/Text-Diff-HTML/trunk/
98 <https://svn.kineticode.com/Text-Diff-HTML/trunk/>
99
100 Patches against SVN::Notify are welcome. Please send bug reports to
101 <bug-text-diff-html@rt.cpan.org>.
102
104 David Wheeler <david@kineticode.com>
105
107 Copyright (c) 2005-2008 Kineticode, Inc. Some Rights Reserved.
108
109 This module is free software; you can redistribute it and/or modify it
110 under the same terms as Perl itself.
111
112
113
114perl v5.12.0 2010-05-07 Text::Diff::HTML(3)