Diffing paragraphs


#1

Hi all,

Is there a decent equivalent of Perl’s Text::ParagraphDiff[1] that I can
use with Rails to show differences between two versions of a story?

I’ve found something called xhtmldiff, but it requires funky REXML
objects that I can’t get to play nice with simple_format(). The diff
algorithm that comes with Instiki is nice, but it doesn’t seem to scale
(works okay on 500 characters, appears to hang > 1000, which is still
rather short).


Marshall Roch

[1]


#2

there is an htmldiff module that comes with spark that may work for you.

http://rubyforge.org/frs/?group_id=418


#3

On Sun, 4 Dec 2005, Marshall Roch wrote:

Hi all,

Is there a decent equivalent of Perl’s Text::ParagraphDiff[1] that I can
use with Rails to show differences between two versions of a story?

I’ve found something called xhtmldiff, but it requires funky REXML objects
that I can’t get to play nice with simple_format(). The diff algorithm that
comes with Instiki is nice, but it doesn’t seem to scale (works okay on 500
characters, appears to hang > 1000, which is still rather short).

http://raa.ruby-lang.org/project/docdiff/
http://raa.ruby-lang.org/project/diff-lcs/
http://raa.ruby-lang.org/project/algorithm-diff/
http://raa.ruby-lang.org/project/simple-diff/

however, if performance we’re key you’d have to come up with an
extremely good
reason not to use

require “tempfile”

a = Tempfile::new “a#{ rand }”
b = Tempfile::new “b#{ rand }”

a.write “some text”
b.write “some other text”

a.close
b.close

diff = diff -bBu #{ a.path } #{ b.path }

a.close!
b.close!

regards.

-a

===============================================================================
| ara [dot] t [dot] howard [at] noaa [dot] gov
| all happiness comes from the desire for others to be happy. all misery
| comes from the desire for oneself to be happy.
| – bodhicaryavatara