Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
diff2html-cli
Advanced tools
Diff to Html generates pretty HTML diffs from unified and git diff output in your terminal
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 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 |
--sc | --synchronisedScroll | Synchronised horizontal scroll | true , false | true |
--hc | --highlightCode | Highlight code | true , false | true |
--su | --summary | Show files summary | closed , open , hidden | closed |
-d | --diffStyle | Diff style | word , char | word |
--lm | --matching | Diff line matching type | lines , words , none | none |
--lmt | --matchWordsThreshold | Diff line matching word threshold | 0.25 | |
--lmm | --matchingMaxComparisons | Diff line matching maximum line comparisons of a block of changes | 2500 | |
--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 | false | ||
--maxLineSizeInBlockForComparison | Maximum number of characters of the bigger line in a block to apply comparison | 200 | ||
--maxLineLengthHighlight | Maximum number of characters in a line to apply highlight | 10000 | ||
--hwt | --htmlWrapperTemplate | Path to custom template to be rendered when using the html output format | [string] | |
-f | --format | Output format | html , json | html |
-i | --input | Diff input source | file , command , stdin | command |
-o | --output | Output destination | preview , stdout | preview |
-u | --diffy | Upload to diffy.org | browser , pbcopy , print | |
-F | --file | Send output to file (overrides output option) | [string] | |
--ig | --ignore | Ignore particular files from the diff | [string] | |
-v | --version | Show version number | ||
-h | --help | Show help |
--hwt | --htmlWrapperTemplate
is not a valid fileThe 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:
<head>
tag<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" />
<!--diff2html-css-->
<!--diff2html-js-ui-->
<script>
document.addEventListener('DOMContentLoaded', () => {
const targetElement = document.getElementById('diff');
const diff2htmlUi = new Diff2HtmlUI(targetElement);
//diff2html-fileListToggle
//diff2html-synchronisedScroll
//diff2html-highlightCode
});
</script>
<body>
tag<div id="diff">
<!--diff2html-diff-->
</div>
diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1
diff2html -i file -- my-file-diff.diff
diff -u file1.txt file2.txt | diff2html -i stdin
diff2html -f json -o stdout -- -M HEAD~1
diff2html -F my-pretty-diff.html -- -M HEAD~1
diff2html -F my-pretty-diff.html --hwt my-custom-template.html -- -M HEAD~1
diff2html --ig package-lock.json --ig yarn.lock
package-lock.json
and yarn.lock
from the generated diffNOTE: notice the --
in the examples
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.
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.
FAQs
Fast Diff to colorized HTML
The npm package diff2html-cli receives a total of 15,830 weekly downloads. As such, diff2html-cli popularity was classified as popular.
We found that diff2html-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.