Project

diffed

0.0
No commit activity in last 3 years
No release in over 3 years
This is a library for creating HTML from a unified diff string, built specifically for the diff section output by "perforce describe -du" or "git show [commit SHA]", but with an eye towards solving a more general problem. It supports two modes: with inline styles or with CSS classes(which you can style yourself). Either mode outputs an HTML table that you may want to include in a Web page or an HTML e-mail.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Diffed Build Status

This is a library for creating HTML from a unified diff string. Currently the only use-case I am building is for retrieving diffs from p4 describe -du 123456 and sending the HTML in an e-mail. Hopefully I can generalise the problem to add other use-cases.

Installation

Add this line to your application's Gemfile:

gem 'diffed'

And then execute:

$ bundle

Or install it yourself as:

$ gem install diffed

Usage

Assuming you have a unified diff output in a string called diff_output, you can format it like this:

require 'diffed'

html = Diffed::Diff.new(diff_output).as_html_table

By default, this will print the HTML table with inline CSS styles (e.g., style="color: #FDD"), for maximum compatibility when sending HTML e-mails and for inclusion in other HTML documents without having to load separate stylesheets.

If you'd like to style the HTML yourself, you can have the table render with CSS classes instead of inline styles, like so:

html = Diffed::Diff.new(diff_output).as_html_table(false)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request