Forum: Ruby on Rails Diffing paragraphs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
marshall (Guest)
on 2005-12-04 14:55
(Received via mailing list)
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]
http://search.cpan.org/~jryan/Text-ParagraphDiff-2...
vanek (Guest)
on 2005-12-04 17:38
(Received via mailing list)
there is an htmldiff module that comes with spark that may work for you.

http://rubyforge.org/frs/?group_id=418
ara.t.howard (Guest)
on 2005-12-04 18:19
(Received via mailing list)
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
===============================================================================
This topic is locked and can not be replied to.