2.0.2 • Published 5 years ago

react-gh-like-diff v2.0.2

Weekly downloads
2,959
License
MIT
Repository
github
Last release
5 years ago

react-gh-like-diff

npm Build Status Maintainability codecov styled with prettier npm.io npm.io

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,
  maxLineSizeInBlockForComparison: 200,
  maxLineLengthHighlight: 10000,
  renderNothingWhenEmpty: false
};

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

Style

Import css style make sure render correctly:

import 'react-gh-like-diff/dist/css/diff2html.min.css';

You also can reference examples.

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

2.0.2

5 years ago

2.0.1-beta.2

5 years ago

2.0.1-beta.1

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.4

5 years ago

1.1.4-beta.1

5 years ago

1.1.4-beta.2

5 years ago

1.1.4-beta.3

5 years ago

1.1.3

5 years ago

1.1.3-beta.2

5 years ago

1.1.3-beta.1

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.7

5 years ago

1.0.6-beta.5

5 years ago

1.0.6

6 years ago

1.0.6-beta.4

6 years ago

1.0.6-beta.3

6 years ago

1.0.6-beta.2

6 years ago

1.0.6-beta.1

6 years ago

1.0.5

6 years ago

1.0.6-beta

6 years ago

1.0.1-beta

6 years ago

1.0.5-beta

6 years ago

1.0.0

6 years ago

0.0.79

7 years ago

0.0.78

7 years ago

0.0.77

7 years ago

0.0.76

7 years ago

0.0.75

7 years ago

0.0.7

7 years ago

0.0.63

7 years ago

0.0.62

7 years ago

0.0.61

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago