samg / diffy

Easy Diffing in Ruby
http://rubygems.org/gems/diffy
MIT License
1.27k stars 104 forks source link

Store as diff, display as HTML #91

Open retronoodle opened 6 years ago

retronoodle commented 6 years ago

Hi there, awesome gem - thank you!

I'd like to store my diffs in a DB as plain text diffs to make them smaller, more portable, etc. This part is easy.

But then, I'd like to pull them out of the DB and display them as HTML - basically with the same output as

Diffy::Diff.default_format = :html

Would give me. I don't want to redo the diff (the info that created the diff is gone at this point).

Maybe something like

Diffy::Diff.convert(stored_diff).to_s(:html)

Seems like I might be missing something or someone else might have solved this problem.

Right now, I am storing the diff as HTML but that wouldn't be as cool b/c later I'd have to strip out the html to display it in a txt environment.

Much thanks!

samg commented 6 years ago

You might be able to do this by invoking the HTML formatter directly.

Something like: Diffy::HtmlFormatter.new(myDiff)