Skip to content

➕➖ The react component to generate pretty HTML for comparing commits or text.

License

Notifications You must be signed in to change notification settings

weih-kahoot/react-gh-like-diff

 
 

Repository files navigation

react-gh-like-diff

Greenkeeper badge npm Build Status Maintainability codecov styled with prettier

react-gh-like-diff

Generate Github like comparison based on diff2html.

You can compare string or given unified diff to generate pretty HTML.

Demo

Edit React Github Like Diff Example

Installation

yarn add react-gh-like-diff

# or

npm install react-gh-like-diff --save

Configuration

react-gh-like-diff is based on diff2html. The default configuration:

const defaultOptions = {
  originalFileName: 'Unknown-File-Name',
  updatedFileName: 'Unknown-File-Name',
  inputFormat: 'diff',
  outputFormat: 'side-by-side',
  showFiles: false,
  matching: 'none',
  matchWordsThreshold: 0.25,
  matchingMaxComparisons: 2500
};

You can custom options for you want, just pass options as props. The configuration you can reference here. 🔎

Props

past

string | defaults to ''

Passing past string as past prop with current prop for comparison.

current

string | defaults to ''

Passing current string as current prop with past prop for comparison.

diffString

string | defaults to ''

Passing unified diff as prop to generate pretty HTML.

options

object | optional, See here

Reference diff2html docs for extra configuration setting.

Inspiration

nakajmg - gh-diff-html

LICENSE

MIT © Peng Jie

About

➕➖ The react component to generate pretty HTML for comparing commits or text.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 83.4%
  • HTML 10.8%
  • CSS 5.8%