Skip to content

Commit e1d7088

Browse files
committed
add support for both wordByWord and charByChar hightlight
1 parent 19f7441 commit e1d7088

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "diff2html-cli",
3-
"version": "0.2.0-2",
3+
"version": "0.2.0-3",
44

55
"homepage": "https://www.github.com/rtfpessoa/diff2html-nodejs-cli",
66
"description": "Fast Diff to colorized HTML",
@@ -56,7 +56,7 @@
5656
"commander": "2.7.1",
5757
"extend": "2.0.0",
5858
"pkginfo": "0.3.0",
59-
"diff2html": "0.2.0-6"
59+
"diff2html": "0.2.0-7"
6060
},
6161

6262
"devDependencies": {

src/main.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ program
1313
.option('-p, --preview', 'Open preview in the browser.')
1414
.option('-l, --line', 'Line by Line diff.')
1515
.option('-s, --side', 'Side by Side diff.')
16+
.option('-w, --word', 'Word by Word highlight.')
17+
.option('-c, --char', 'Char by Char highlight.')
1618
.option('-j, --json', 'Export diff in json format.');
1719

1820
program.on('--help', function () {
@@ -71,11 +73,15 @@ function getInput(program) {
7173
function getHtml(program, input) {
7274
var diff2Html = require('diff2html').Diff2Html;
7375

76+
var config = {};
77+
config.wordByWord = program.word;
78+
config.charByChar = program.char;
79+
7480
if (program.side) {
75-
return diff2Html.getPrettySideBySideHtmlFromDiff(input);
81+
return diff2Html.getPrettySideBySideHtmlFromDiff(input, config);
7682
} else if (program.json) {
77-
return JSON.stringify(diff2Html.getJsonFromDiff(input));
83+
return JSON.stringify(diff2Html.getJsonFromDiff(input, config));
7884
} else {
79-
return diff2Html.getPrettyHtmlFromDiff(input);
85+
return diff2Html.getPrettyHtmlFromDiff(input, config);
8086
}
8187
}

0 commit comments

Comments
 (0)