Skip to content

PrettyDiff is a highly customizable library for creating fully featured HTML listings out of unified diff format strings. Include copy/paste-safe line numbers and built-in syntax highlighting.

License

Notifications You must be signed in to change notification settings

simonoff/pretty_diff

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pretty Diff

A tiny library for generating pretty HTML listings for unified Diff format. Heavily used in Beanstalk (beanstalkapp.com) application.

Installation

gem install pretty_diff

Example

A quick example will tell it all:

udiff = File.read("awesome.diff")
pretty = PrettyDiff::Diff.new(udiff)
pretty.to_html

Wrap it with HTML, add some styles and you will get something like this:

Features

The library is really easy to read and change. All HTML is generated by a set of classes called generators, it’s very easy to customize the output to suit your needs.

By default PrettyDiff will generate HTML that can be easily colored with the CSS that you can find in the example above.

PrettyDiff will generate 2 columns of line numbers, as it’s usually done for diffs. These columns are copy/paste safe, means that line numbers won’t be copied when you copy diff contents.

Tabs will be automatically converted to double spaces.

HTML tags will be automatically escaped from the input string.

To Do

The test suit can be somewhat improved.

History

The library was extracted from Beanstalk during the awesome Wildbit Open Source Fridays.

Read more about Open Source Fridays here:

wildbit.com/blog/2010/01/15/open-source-fridays-at-wildbit/

Contributors

  1. mrsimo

Copyright © 2010 Ilya Sabanin, Wildbit; see LICENSE for details.

About

PrettyDiff is a highly customizable library for creating fully featured HTML listings out of unified diff format strings. Include copy/paste-safe line numbers and built-in syntax highlighting.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%