RFC: HTML::FileDiff -- display diff of two files in HTML 
Author Message
 RFC: HTML::FileDiff -- display diff of two files in HTML

There are various utilities available that will display the output of
diff between two files in HTML.  Surprisingly, I can't find any in
Perl or, more specifically, one that is a Perl module.  It's a rather
simple thing to do so I'm proposing to do it and I'd like somebody to
stop me if they really have seen one before! :-)

marked as under construction, this post is cc'd to Ian.

The module will initially use a ``unified diff'' so that line adds and
deletes are presented together, rather than in the before/after
context that diff normally provides.  I believe this also makes GNU
`diff' a requirement because I believe that only GNU `diff' has a
unified diff option.


    HTML::FileDiff -- highlight differences between two files in HTML

    $differ = HTML::FileDiff->new (...);

    $differ->diff ($file_handle, $file1, $file2, ...);
    $differ->diff (\$scalar, $file1, $file2, ...);
    $differ->page ($file_handle, $file1, $file2, ...);
    $differ->page (\$scalar, $file1, $file2, ...);

    $differ->doctype ('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">');
    $differ->diff_u ('diff -u');
    $differ->body_bgcolor (undef);
    $differ->unchanged_color ('#000000');
    $differ->original_color ('#0000ff');
    $differ->changed_color ('#00ff00');
    $differ->context (20);
      # list of configuration values not complete yet, suggestions welcome

   `HTML::FileDiff->new' returns an object containing the default
   values for subsequent calls to diff or page.

   `diff' generates an HTML rendering of the differences between two
   files.  The rendering will contain one `PRE' element (i.e. starting
   with a `<PRE>' tag and ending with `</PRE>', with the file
   differences between) that can be inserted into other elements or

   `page' generates an HTML page using `diff'.  The page will contain
   a document type declaration, a title, and a section header noting
   the files being diffed.

   If passed a `$file_handle', `diff' and `page' will write output to
   that file handle.  If passed a reference to a scalar, `diff' and
   `page' will append to the scalar.

   The arguments to `new' or calls to change configuration values
   override the built-in defaults (given above in the SYNOPSIS).  The
   argument(s) to `new' or the extra argument(s) to `diff' and `page'
   are either a single hash or a list of key-value pairs containing
   values to override.  For example,

       $my_defaults = { body_bgcolor => '#ffffff', context => 10000 };
       $differ = HTML::FileDiff->new ($my_defaults);


       $differ = HTML::FileDiff->new (body_bgcolor => '#ffffff',
                                      context => 10000);

   The extra arguments to `diff' or `page' apply only to that call.

  Ken MacLeod

Sat, 02 Sep 2000 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. html : how replace inner links in a html file when move a file

2. writing an html file into another html file

3. Insert HTML file into another HTML file

4. can't display HTML file in browser

5. How to display all records in flat-file db using HTML

6. How to Display multiple image files into HTML template with perl

7. Displaying 1 html file in cgi, then second

8. Taking parameters from scrollboxes and then displaying a particular html file

9. Can Perl load and display an html file???

10. Wanted - random GIF file display in HTML

11. Displaying HTML File

12. Form 2 HTML, HTML 2 File


Powered by phpBB® Forum Software