Fast Diff to colorized HTML
npm install diff2html-cli







Diff to Html generates pretty HTML diffs from unified and git diff output in your terminal
- Features
- Online Example
- Distributions
- Setup
- Usage
- Exit Status Codes
- Custom HTML wrapper template
- Examples
- Contribute
- Developing
- License
- Thanks
- Unified diff and Git diff input
- line-by-line and side-by-side diff
- new and old line numbers
- inserted and removed lines
- GitHub like style
- Code syntax highlight
- Line similarity matching
> Go to Diff2HTML
- NPM CLI
- [NPM / Node.js library [ES5 & ES6]](https://github.com/rtfpessoa/diff2html)
- CDNJS
- WebJar
``sh`
npm install -g diff2html-cli
Usage: diff2html [ flags and/or options ] -- [git diff passthrough flags and options]
| flag | alias | description | choices | default |
| ----- | --------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | --------- |
| -s | --style | Output style | line, side | line |true
| --fct | --fileContentToggle | Adds a viewed checkbox to toggle file content | , false | true |true
| --sc | --synchronisedScroll | Synchronised horizontal scroll | , false | true |true
| --hc | --highlightCode | Highlight code | , false | true |auto
| --cs | --colorScheme | Color scheme | , dark, light | auto |closed
| --su | --summary | Show files summary | , open, hidden | closed |word
| -d | --diffStyle | Diff style | , char | word |lines
| --lm | --matching | Diff line matching type | , words, none | none |0.25
| --lmt | --matchWordsThreshold | Diff line matching word threshold | | |2500
| --lmm | --matchingMaxComparisons | Diff line matching maximum line comparisons of a block of changes | | |false
| | --diffMaxChanges | Number of changed lines after which a file diff is deemed as too big and not displayed | | |
| | --diffMaxLineLength | Number of characters in a diff line after which a file diff is deemed as too big and not displayed | | |
| | --renderNothingWhenEmpty | Render nothing if the diff shows no change in its comparison | | |200
| | --maxLineSizeInBlockForComparison | Maximum number of characters of the bigger line in a block to apply comparison | | |10000
| | --maxLineLengthHighlight | Maximum number of characters in a line to apply highlight | | |html
| --hwt | --htmlWrapperTemplate | Path to custom template to be rendered when using the output format | [string] |html
| -t | --title | Page title for output | [string] |html
| -f | --format | Output format | , json | html |file
| -i | --input | Diff input source | , command, stdin | command |preview
| -o | --output | Output destination | , stdout | preview |browser
| -u | --diffy | Upload to diffy.org | , pbcopy, print | |[string]
| -F | --file | Send output to file (overrides output option) | | |[string]
| --ig | --ignore | Ignore particular files from the diff | | |
| -v | --version | Show version number | | |
| -h | --help | Show help | | |
- :tada: 0: Success
- :dizzy_face: 1: Generic Error
- :cold_sweat: 3: Input diff is empty
- :cop: 4: Value of --hwt | --htmlWrapperTemplate is not a valid file
The template is a very based on a simple replace of several placeholders as coded
https://github.com/rtfpessoa/diff2html-cli/blob/master/src/cli.ts#L40
To provide a custom template you need to make sure you have the following comments and imports in your HTML, exactly as
they are here:
- Inside the
tag`html
`- Inside the
tag`html
`$3
diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1- diff last commit, line by line, word comparison between lines, previewed in the browser and input from git diff
command
diff2html -i file -- my-file-diff.diff- reading the input from a file
diff -u file1.txt file2.txt | diff2html -i stdin- reading diff from stdin
diff2html -f json -o stdout -- -M HEAD~1- print json format to stdout
diff2html -F my-pretty-diff.html -- -M HEAD~1- print to file
diff2html -F my-pretty-diff.html --hwt my-custom-template.html -- -M HEAD~1- print to file using custom markup templates can include the following variables
diff2html --ig package-lock.json --ig yarn.lock- Ignore
package-lock.json and yarn.lock from the generated diff_NOTE_: notice the
-- in the examplesContribute
This is a developer friendly project, all the contributions are welcome. To contribute just send a pull request with
your changes following the guidelines described in
CONTRIBUTING.md. I will try to review them as soon as possible.Developing
Make some changes,
yarn build and then ./bin/diff2html` 😉Copyright 2014-present Rodrigo Fernandes. Released under the terms of the MIT license.
This project is inspired in pretty-diff by
Scott González.
---