|
NAMEText::ParagraphDiff - Visual Difference for paragraphed text.ABSTRACT"Text::ParagraphDiff" finds the difference between two paragraphed text files by word rather than by line, reflows the text together, and then outputs result as xhtml.SYNOPSISuse Text::ParagraphDiff; # old.txt and new.txt are filenames print text_diff('old.txt', 'new.txt'); # Or pass array references print text_diff(\@old, \@new); # T-Diff 2 plain strings (a FAQ) print text_diff("old", "new", {string=>1}); # Pass options (see below) print text_diff($old, $new, {plain=>1}); # or use the premade script in bin/: # ./tdiff oldfile newfile DESCRIPTION"Text::ParagraphDiff" is a reimplementation of "diff" that is meant for paragraphed text rather than for code. Instead of "diffing" a document by line, "Text::ParagraphDiff" expands a document to one word per line, uses "Algorithm::Diff" to find the difference, and then reflows the text back together, highlighting the "add" and "subtract" sections. Writers and editors might find this useful for sending revisions to each other across the internet, or a single user might use it to keep track of personal work. For example output, please see diff.html in the distribution, as well as the sources for the difference, old.txt and new.txt.The output is in xhtml, for ease of generation, ease of access, and ease of viewing. "Text::ParagraphDiff" also takes advantage of two advanced features of the median: CSS and JavaScript. CSS is used to cut down on output size and to make the output very pleasing to the eye. JavaScript is used to implement additional functionality: two buttons that can toggle the display of the difference. CSS and JavaScript can be turned off; see the "plain" option below. (Note: CSS & Javascript tested with Mozilla 1.0, Camino 0.7, and IE 5.x) EXPORT"text_diff" is exported by default.Additionally, "create_diff", "html_header", and "html_footer" are optionally exported by request (e.g. use "Text::ParagraphDiff qw(create_diff))". "create_diff" is the actual diff itself; "html_header" and "html_footer" should be obvious. OPTIONS"text_diff" is the suggested interface, and it can be configured with a number of different options.Options are stored in a hashref, $opt. $opt is an optional last argument to "text_diff", passed like this: text_diff($old, $new, { plain => 1, escape => 1, string => 1, minus_first => 1, functionality => 1, style => 'stylesheet_code_here', header => 'header_markup_here', sep => ['<p>','</p>'] }); All options are, uh, optional. Options are:
BUGSIn old versions, some situations of deletion of entire paragraphs in special places might make the surrounding line-breaks become whacky. Although this bug is theoretically fixed, if you do encounter it, let me know. If you can isolate the case, please send me a bug report, I might be able to fix it. In the mean time, if this does happen to you, just fix the output's markup by hand, as it shouldn't be too complicated.AUTHORJoseph F. Ryan (ryan.311@osu.edu) Tests done by Jonas Liljegren (jonas@liljegren.org)SEE ALSO"Algorithm::Diff".
Visit the GSP FreeBSD Man Page Interface. |