diff2html
Advanced tools
Comparing version 2.0.0-beta17 to 2.0.0-beta18
{ | ||
"name": "diff2html", | ||
"version": "2.0.0-beta17", | ||
"version": "2.0.0-beta18", | ||
"homepage": "http://rtfpessoa.github.io/diff2html/", | ||
@@ -5,0 +5,0 @@ "description": "Fast Diff to colorized HTML", |
@@ -16,3 +16,3 @@ # diff2html | ||
diff2html generates pretty HTML diffs from git diff output. | ||
diff2html generates pretty HTML diffs from git or unified diff output. | ||
@@ -23,2 +23,4 @@ [](https://nodei.co/npm/diff2html/) | ||
* Supports git and unified diffs | ||
* Line by line and Side by side diff | ||
@@ -25,0 +27,0 @@ |
@@ -36,5 +36,4 @@ /* | ||
/* Add previous block(if exists) before start a new file */ | ||
var saveBlock = function() { | ||
/* Add previous block(if exists) before start a new file */ | ||
if (currentBlock) { | ||
@@ -46,8 +45,7 @@ currentFile.blocks.push(currentBlock); | ||
/* | ||
* Add previous file(if exists) before start a new one | ||
* if it has name (to avoid binary files errors) | ||
*/ | ||
var saveFile = function() { | ||
/* | ||
* Add previous file(if exists) before start a new one | ||
* if it has name (to avoid binary files errors) | ||
*/ | ||
if (currentFile && currentFile.newName) { | ||
@@ -59,2 +57,3 @@ files.push(currentFile); | ||
/* Create file structure */ | ||
var startFile = function() { | ||
@@ -64,3 +63,2 @@ saveBlock(); | ||
/* Create file structure */ | ||
currentFile = {}; | ||
@@ -186,14 +184,68 @@ currentFile.blocks = []; | ||
var values = []; | ||
if (utils.startsWith(line, 'diff')) { | ||
if ( | ||
utils.startsWith(line, 'diff') || // Git diffs always start with diff | ||
!currentFile || // If we do not have a file yet, we should crete one | ||
( | ||
currentFile && // If we already have some file in progress and | ||
( | ||
currentFile.oldName && utils.startsWith(line, '---') || // Either we reached a old file identification line | ||
currentFile.newName && utils.startsWith(line, '+++') // Or we reached a new file identification line | ||
) | ||
) | ||
) { | ||
startFile(); | ||
} else if (currentFile && !currentFile.oldName && (values = getSrcFilename(line, config))) { | ||
} | ||
var values; | ||
/* | ||
* --- Date Timestamp[FractionalSeconds] TimeZone | ||
* --- 2002-02-21 23:30:39.942229878 -0800 | ||
*/ | ||
if (currentFile && !currentFile.oldName && | ||
utils.startsWith(line, '---') && (values = getSrcFilename(line, config))) { | ||
currentFile.oldName = values; | ||
currentFile.language = getExtension(currentFile.oldName, currentFile.language); | ||
} else if (currentFile && !currentFile.newName && (values = getDstFilename(line, config))) { | ||
return; | ||
} | ||
/* | ||
* +++ Date Timestamp[FractionalSeconds] TimeZone | ||
* +++ 2002-02-21 23:30:39.942229878 -0800 | ||
*/ | ||
if (currentFile && !currentFile.newName && | ||
utils.startsWith(line, '+++') && (values = getDstFilename(line, config))) { | ||
currentFile.newName = values; | ||
currentFile.language = getExtension(currentFile.newName, currentFile.language); | ||
} else if (currentFile && utils.startsWith(line, '@@')) { | ||
return; | ||
} | ||
if (currentFile && utils.startsWith(line, '@')) { | ||
startBlock(line); | ||
} else if ((values = oldMode.exec(line))) { | ||
return; | ||
} | ||
/* | ||
* There are three types of diff lines. These lines are defined by the way they start. | ||
* 1. New line starts with: + | ||
* 2. Old line starts with: - | ||
* 3. Context line starts with: <SPACE> | ||
*/ | ||
if (currentBlock && (utils.startsWith(line, '+') || utils.startsWith(line, '-') || utils.startsWith(line, ' '))) { | ||
createLine(line); | ||
return; | ||
} | ||
if ( | ||
(currentFile && currentFile.blocks.length) || | ||
(currentBlock && currentBlock.lines.length) | ||
) { | ||
startFile(); | ||
} | ||
/* | ||
* Git diffs provide more information regarding files modes, renames, copies, | ||
* commits between changes and similarity indexes | ||
*/ | ||
if ((values = oldMode.exec(line))) { | ||
currentFile.oldMode = values[1]; | ||
@@ -240,4 +292,2 @@ } else if ((values = newMode.exec(line))) { | ||
currentFile.isDeleted = true; | ||
} else if (currentBlock) { | ||
createLine(line); | ||
} | ||
@@ -244,0 +294,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
280296
5331
181