diff --git a/bower.json b/bower.json index 0438595..a3e33ce 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "diff2html", - "version": "1.1.3", + "version": "1.2.0", "homepage": "http://rtfpessoa.github.io/diff2html/", "description": "Fast Diff to colorized HTML", "keywords": [ diff --git a/dist/diff2html.css b/dist/diff2html.css index 7b7e8b5..7a69479 100644 --- a/dist/diff2html.css +++ b/dist/diff2html.css @@ -256,6 +256,19 @@ clear: both; } +.d2h-del.d2h-change, .d2h-ins.d2h-change { + background-color: #ffc; +} +ins.d2h-change, del.d2h-change { + background-color: #fad771; +} +.d2h-file-diff .d2h-del.d2h-change { + background-color: #fae1af; +} +.d2h-file-diff .d2h-ins.d2h-change { + background-color: #ded; +} + /* CSS only show/hide */ .d2h-show { display: none; diff --git a/dist/diff2html.js b/dist/diff2html.js index a2a9f70..bfc292d 100644 --- a/dist/diff2html.js +++ b/dist/diff2html.js @@ -55,7 +55,7 @@ var diffParser = __webpack_require__(1).DiffParser; var fileLister = __webpack_require__(3).FileListPrinter; - var htmlPrinter = __webpack_require__(20).HtmlPrinter; + var htmlPrinter = __webpack_require__(21).HtmlPrinter; function Diff2Html() { } @@ -175,6 +175,8 @@ var LINE_TYPE = { INSERTS: 'd2h-ins', DELETES: 'd2h-del', + INSERT_CHANGES: 'd2h-ins d2h-change', + DELETE_CHANGES: 'd2h-del d2h-change', CONTEXT: 'd2h-cntx', INFO: 'd2h-info' }; @@ -503,6 +505,7 @@ var jsDiff = __webpack_require__(5); var utils = __webpack_require__(2).Utils; + var Rematch = __webpack_require__(20).Rematch; function PrinterUtils() { } @@ -563,12 +566,42 @@ var highlightedLine = ''; + var changedWords = []; + if (!config.charByChar && config.matching === 'words') { + var treshold = 0.25; + if (typeof(config.matchWordsThreshold) !== "undefined") { + treshold = config.matchWordsThreshold; + } + var matcher = Rematch.rematch(function(a, b) { + var amod = a.value, + bmod = b.value, + result = Rematch.distance(amod, bmod); + return result; + }); + var removed = diff.filter(function isRemoved(element){ + return element.removed; + }); + var added = diff.filter(function isAdded(element){ + return element.added; + }); + var chunks = matcher(added, removed); + chunks = chunks.forEach(function(chunk){ + if(chunk[0].length === 1 && chunk[1].length === 1) { + var dist = Rematch.distance(chunk[0][0].value, chunk[1][0].value) + if (dist < treshold) { + changedWords.push(chunk[0][0]); + changedWords.push(chunk[1][0]); + } + } + }); + } diff.forEach(function(part) { + var addClass = changedWords.indexOf(part) > -1 ? ' class="d2h-change"' : ''; var elemType = part.added ? 'ins' : part.removed ? 'del' : null; var escapedValue = utils.escape(part.value); if (elemType !== null) { - highlightedLine += '<' + elemType + '>' + escapedValue + ''; + highlightedLine += '<' + elemType + addClass + '>' + escapedValue + ''; } else { highlightedLine += escapedValue; } @@ -591,11 +624,11 @@ } function removeIns(line) { - return line.replace(/(((.|\n)*?)<\/ins>)/g, ''); + return line.replace(/(]*>((.|\n)*?)<\/ins>)/g, ''); } function removeDel(line) { - return line.replace(/(((.|\n)*?)<\/del>)/g, ''); + return line.replace(/(]*>((.|\n)*?)<\/del>)/g, ''); } module.exports['PrinterUtils'] = new PrinterUtils(); @@ -1430,41 +1463,42 @@ var index = {}; list.push(index); - // Ignore any leading junk + // Parse diff metadata while (i < diffstr.length) { - if (/^(Index:|diff -r|@@)/.test(diffstr[i])) { + var line = diffstr[i]; + + // File header found, end parsing diff metadata + if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { break; } - i++; - } - var header = /^(?:Index:|diff(?: -r \w+)+) (.*)/.exec(diffstr[i]); - if (header) { - index.index = header[1]; - i++; - - if (/^===/.test(diffstr[i])) { - i++; + // Diff index + var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line); + if (header) { + index.index = header[1]; } - parseFileHeader(index); - parseFileHeader(index); - } else { - // Ignore erant header components that might occur at the start of the file - parseFileHeader({}); - parseFileHeader({}); + i++; } + // Parse file headers if they are defined. Unified diff requires them, but + // there's no technical issues to have an isolated hunk without file header + parseFileHeader(index); + parseFileHeader(index); + + // Parse hunks index.hunks = []; while (i < diffstr.length) { - if (/^(Index:|diff -r)/.test(diffstr[i])) { + var line = diffstr[i]; + + if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(line)) { break; - } else if (/^@@/.test(diffstr[i])) { + } else if (/^@@/.test(line)) { index.hunks.push(parseHunk()); - } else if (diffstr[i] && options.strict) { + } else if (line && options.strict) { // Ignore unexpected content unless in strict mode - throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(diffstr[i])); + throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(line)); } else { i++; } @@ -1474,7 +1508,7 @@ // Parses the --- and +++ headers, if none are found, no lines // are consumed. function parseFileHeader(index) { - var fileHeader = /^(\-\-\-|\+\+\+)\s(\S+)\s?(.*)/.exec(diffstr[i]); + var fileHeader = /^(\-\-\-|\+\+\+)\s+(\S+)\s?(.+?)\s*$/.exec(diffstr[i]); if (fileHeader) { var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; index[keyPrefix + 'FileName'] = fileHeader[2]; @@ -1547,7 +1581,7 @@ return list; } - //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wYXRjaC9wYXJzZS5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFPLFNBQVMsVUFBVSxDQUFDLE9BQU8sRUFBZ0I7TUFBZCxPQUFPLHlEQUFHLEVBQUU7O0FBQzlDLE1BQUksT0FBTyxHQUFHLE9BQU8sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDO01BQzdCLElBQUksR0FBRyxFQUFFO01BQ1QsQ0FBQyxHQUFHLENBQUMsQ0FBQzs7QUFFVixXQUFTLFVBQVUsR0FBRztBQUNwQixRQUFJLEtBQUssR0FBRyxFQUFFLENBQUM7QUFDZixRQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDOzs7QUFHakIsV0FBTyxDQUFDLEdB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gY2h1bmtIZWFkZXJMaW5lID0gZGlmZnN0cltpKytdLFxuICAgICAgICBjaHVua0hlYWRlciA9IGNodW5rSGVhZGVyTGluZS5zcGxpdCgvQEAgLShcXGQrKSg/OiwoXFxkKykpPyBcXCsoXFxkKykoPzosKFxcZCspKT8gQEAvKTtcblxuICAgIGxldCBodW5rID0ge1xuICAgICAgb2xkU3RhcnQ6ICtjaHVua0hlYWRlclsxXSxcbiAgICAgIG9sZExpbmVzOiArY2h1bmtIZWFkZXJbMl0gfHwgMSxcbiAgICAgIG5ld1N0YXJ0OiArY2h1bmtIZWFkZXJbM10sXG4gICAgICBuZXdMaW5lczogK2NodW5rSGVhZGVyWzRdIHx8IDEsXG4gICAgICBsaW5lczogW11cbiAgICB9O1xuXG4gICAgbGV0IGFkZENvdW50ID0gMCxcbiAgICAgICAgcmVtb3ZlQ291bnQgPSAwO1xuICAgIGZvciAoOyBpIDwgZGlmZnN0ci5sZW5ndGg7IGkrKykge1xuICAgICAgbGV0IG9wZXJhdGlvbiA9IGRpZmZzdHJbaV1bMF07XG5cbiAgICAgIGlmIChvcGVyYXRpb24gPT09ICcrJyB8fCBvcGVyYXRpb24gPT09ICctJyB8fCBvcGVyYXRpb24gPT09ICcgJyB8fCBvcGVyYXRpb24gPT09ICdcXFxcJykge1xuICAgICAgICBodW5rLmxpbmVzLnB1c2goZGlmZnN0cltpXSk7XG5cbiAgICAgICAgaWYgKG9wZXJhdGlvbiA9PT0gJysnKSB7XG4gICAgICAgICAgYWRkQ291bnQrKztcbiAgICAgICAgfSBlbHNlIGlmIChvcGVyYXRpb24gPT09ICctJykge1xuICAgICAgICAgIHJlbW92ZUNvdW50Kys7XG4gICAgICAgIH0gZWxzZSBpZiAob3BlcmF0aW9uID09PSAnICcpIHtcbiAgICAgICAgICBhZGRDb3VudCsrO1xuICAgICAgICAgIHJlbW92ZUNvdW50Kys7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGJyZWFrO1xuICAgICAgfVxuICAgIH1cblxuICAgIC8vIEhhbmRsZSB0aGUgZW1wdHkgYmxvY2sgY291bnQgY2FzZVxuICAgIGlmICghYWRkQ291bnQgJiYgaHVuay5uZXdMaW5lcyA9PT0gMSkge1xuICAgICAgaHVuay5uZXdMaW5lcyA9IDA7XG4gICAgfVxuICAgIGlmICghcmVtb3ZlQ291bnQgJiYgaHVuay5vbGRMaW5lcyA9PT0gMSkge1xuICAgICAgaHVuay5vbGRMaW5lcyA9IDA7XG4gICAgfVxuXG4gICAgLy8gUGVyZm9ybSBvcHRpb25hbCBzYW5pdHkgY2hlY2tpbmdcbiAgICBpZiAob3B0aW9ucy5zdHJpY3QpIHtcbiAgICAgIGlmIChhZGRDb3VudCAhPT0gaHVuay5uZXdMaW5lcykge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0FkZGVkIGxpbmUgY291bnQgZGlkIG5vdCBtYXRjaCBmb3IgaHVuayBhdCBsaW5lICcgKyAoY2h1bmtIZWFkZXJJbmRleCArIDEpKTtcbiAgICAgIH1cbiAgICAgIGlmIChyZW1vdmVDb3VudCAhPT0gaHVuay5vbGRMaW5lcykge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1JlbW92ZWQgbGluZSBjb3VudCBkaWQgbm90IG1hdGNoIGZvciBodW5rIGF0IGxpbmUgJyArIChjaHVua0hlYWRlckluZGV4ICsgMSkpO1xuICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiBodW5rO1xuICB9XG5cbiAgd2hpbGUgKGkgPCBkaWZmc3RyLmxlbmd0aCkge1xuICAgIHBhcnNlSW5kZXgoKTtcbiAgfVxuXG4gIHJldHVybiBsaXN0O1xufVxuIl19 + //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wYXRjaC9wYXJzZS5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFPLFNBQVMsVUFBVSxDQUFDL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d0aCkge1xuICAgIHBhcnNlSW5kZXgoKTtcbiAgfVxuXG4gIHJldHVybiBsaXN0O1xufVxuIl19 /***/ }, @@ -1848,6 +1882,146 @@ /***/ }, /* 20 */ +/***/ function(module, exports) { + + /* + * + * Rematch (rematch.js) + * Matching two sequences of objects by similarity + * Author: W. Illmeyer, Nexxar GmbH + * + */ + + (function(ctx, undefined) { + var Rematch = {}; + Rematch.arrayToString = function arrayToString(a) { + if (Object.prototype.toString.apply(a,[]) === "[object Array]") { + return "[" + a.map(arrayToString).join(", ") + "]"; + } else { + return a; + } + } + + /* + Copyright (c) 2011 Andrei Mackenzie + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + function levenshtein(a, b){ + if(a.length == 0) return b.length; + if(b.length == 0) return a.length; + + var matrix = []; + + // increment along the first column of each row + var i; + for(i = 0; i <= b.length; i++){ + matrix[i] = [i]; + } + + // increment each column in the first row + var j; + for(j = 0; j <= a.length; j++){ + matrix[0][j] = j; + } + + // Fill in the rest of the matrix + for(i = 1; i <= b.length; i++){ + for(j = 1; j <= a.length; j++){ + if(b.charAt(i-1) == a.charAt(j-1)){ + matrix[i][j] = matrix[i-1][j-1]; + } else { + matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution + Math.min(matrix[i][j-1] + 1, // insertion + matrix[i-1][j] + 1)); // deletion + } + } + } + return matrix[b.length][a.length]; + } + Rematch.levenshtein = levenshtein; + + Rematch.distance = function distance(x,y) { + x=x.trim(); + y=y.trim(); + var lev = levenshtein(x,y), + score = lev / (x.length + y.length); + return score; + } + + Rematch.rematch = function rematch(distanceFunction) { + + function findBestMatch(a, b, cache) { + var cachecount = 0; + + for(var key in cache) { + cachecount++; + } + var bestMatchDist = Infinity; + var bestMatch; + for (var i = 0; i < a.length; ++i) { + for (var j = 0; j < b.length; ++j) { + var cacheKey = JSON.stringify([a[i], b[j]]); + var md; + if (cache.hasOwnProperty(cacheKey)) { + md = cache[cacheKey]; + } else { + md = distanceFunction(a[i], b[j]); + cache[cacheKey] = md; + } + if (md < bestMatchDist) { + bestMatchDist = md; + bestMatch = { indexA: i, indexB: j, score: bestMatchDist }; + } + } + } + return bestMatch; + } + function group(a, b, level, cache) { + + if (typeof(cache)==="undefined") { + cache = {}; + } + var minLength = Math.min(a.length, b.length); + var bm = findBestMatch(a,b, cache); + if (!level) { + level = 0; + } + if (!bm || (a.length + b.length < 3)) { + return [[a, b]]; + } + var a1 = a.slice(0, bm.indexA), + b1 = b.slice(0, bm.indexB), + aMatch = [a[bm.indexA]], + bMatch = [b[bm.indexB]], + tailA = bm.indexA + 1, + tailB = bm.indexB + 1, + a2 = a.slice(tailA), + b2 = b.slice(tailB); + + var group1 = group(a1, b1, level+1, cache); + var groupMatch = group(aMatch, bMatch, level+1, cache); + var group2 = group(a2, b2, level+1, cache); + var result = groupMatch; + if (bm.indexA > 0 || bm.indexB > 0) { + result = group1.concat(result); + } + if (a.length > tailA || b.length > tailB ) { + result = result.concat(group2); + } + return result; + } + return group; + } + + module.exports['Rematch'] = Rematch; + + })(this); + + +/***/ }, +/* 21 */ /***/ function(module, exports, __webpack_require__) { /* @@ -1859,8 +2033,8 @@ (function(ctx, undefined) { - var lineByLinePrinter = __webpack_require__(21).LineByLinePrinter; - var sideBySidePrinter = __webpack_require__(22).SideBySidePrinter; + var lineByLinePrinter = __webpack_require__(22).LineByLinePrinter; + var sideBySidePrinter = __webpack_require__(23).SideBySidePrinter; function HtmlPrinter() { } @@ -1875,7 +2049,7 @@ /***/ }, -/* 21 */ +/* 22 */ /***/ function(module, exports, __webpack_require__) { /* @@ -1890,6 +2064,7 @@ var diffParser = __webpack_require__(1).DiffParser; var printerUtils = __webpack_require__(4).PrinterUtils; var utils = __webpack_require__(2).Utils; + var Rematch = __webpack_require__(20).Rematch; function LineByLinePrinter() { } @@ -1931,6 +2106,12 @@ '\n'; }; + var matcher=Rematch.rematch(function(a,b) { + var amod = a.content.substr(1), + bmod = b.content.substr(1); + return Rematch.distance(amod, bmod); + }); + function generateFileHtml(file, config) { return file.blocks.map(function(block) { @@ -1943,27 +2124,30 @@ var oldLines = []; var newLines = []; - var processedOldLines = []; - var processedNewLines = []; - - for (var i = 0; i < block.lines.length; i++) { - var line = block.lines[i]; - var escapedLine = utils.escape(line.content); - - if (line.type == diffParser.LINE_TYPE.CONTEXT && !oldLines.length && !newLines.length) { - lines += generateLineHtml(line.type, line.oldNumber, line.newNumber, escapedLine); - } else if (line.type == diffParser.LINE_TYPE.INSERTS && !oldLines.length && !newLines.length) { - lines += generateLineHtml(line.type, line.oldNumber, line.newNumber, escapedLine); - } else if (line.type == diffParser.LINE_TYPE.DELETES && !newLines.length) { - oldLines.push(line); - } else if (line.type == diffParser.LINE_TYPE.INSERTS && oldLines.length > newLines.length) { - newLines.push(line); + function processChangeBlock() { + var matches; + var insertType; + var deleteType; + var doMatching = config.matching === "lines" || config.matching === "words"; + if (doMatching) { + matches = matcher(oldLines, newLines); + insertType = diffParser.LINE_TYPE.INSERT_CHANGES; + deleteType = diffParser.LINE_TYPE.DELETE_CHANGES; } else { + matches = [[oldLines,newLines]]; + insertType = diffParser.LINE_TYPE.INSERTS; + deleteType = diffParser.LINE_TYPE.DELETES; + } + matches.forEach(function(match){ + var oldLines = match[0]; + var newLines = match[1]; + var processedOldLines = []; + var processedNewLines = []; var j = 0; - var oldLine, newLine; - - if (oldLines.length === newLines.length) { - for (j = 0; j < oldLines.length; j++) { + var oldLine, newLine, + common = Math.min(oldLines.length, newLines.length), + max = Math.max(oldLines.length, newLines.length); + for (j = 0; j < common; j++) { oldLine = oldLines[j]; newLine = newLines[j]; @@ -1971,27 +2155,46 @@ var diff = printerUtils.diffHighlight(oldLine.content, newLine.content, config); processedOldLines += - generateLineHtml(oldLine.type, oldLine.oldNumber, oldLine.newNumber, + generateLineHtml(deleteType, oldLine.oldNumber, oldLine.newNumber, diff.first.line, diff.first.prefix); processedNewLines += - generateLineHtml(newLine.type, newLine.oldNumber, newLine.newNumber, + generateLineHtml(insertType, newLine.oldNumber, newLine.newNumber, diff.second.line, diff.second.prefix); } lines += processedOldLines + processedNewLines; - } else { - lines += processLines(oldLines, newLines); - } + lines += processLines(oldLines.slice(common), newLines.slice(common)); - oldLines = []; - newLines = []; - processedOldLines = []; - processedNewLines = []; - i--; + processedOldLines = []; + processedNewLines = []; + }); + oldLines = []; + newLines = []; + } + + for (var i = 0; i < block.lines.length; i++) { + var line = block.lines[i]; + var escapedLine = utils.escape(line.content); + + if ( line.type !== diffParser.LINE_TYPE.INSERTS && + (newLines.length > 0 || (line.type !== diffParser.LINE_TYPE.DELETES && oldLines.length > 0))) { + processChangeBlock(); + } + if (line.type == diffParser.LINE_TYPE.CONTEXT) { + lines += generateLineHtml(line.type, line.oldNumber, line.newNumber, escapedLine); + } else if (line.type == diffParser.LINE_TYPE.INSERTS && !oldLines.length) { + lines += generateLineHtml(line.type, line.oldNumber, line.newNumber, escapedLine); + } else if (line.type == diffParser.LINE_TYPE.DELETES) { + oldLines.push(line); + } else if (line.type == diffParser.LINE_TYPE.INSERTS && !!oldLines.length) { + newLines.push(line); + } else { + console.error('unknown state in html line-by-line generator'); + processChangeBlock(); } } - lines += processLines(oldLines, newLines); + processChangeBlock(); return lines; }).join('\n'); @@ -2053,7 +2256,7 @@ /***/ }, -/* 22 */ +/* 23 */ /***/ function(module, exports, __webpack_require__) { /* @@ -2068,6 +2271,7 @@ var diffParser = __webpack_require__(1).DiffParser; var printerUtils = __webpack_require__(4).PrinterUtils; var utils = __webpack_require__(2).Utils; + var Rematch = __webpack_require__(20).Rematch; function SideBySidePrinter() { } @@ -2120,6 +2324,12 @@ '\n'; }; + var matcher=Rematch.rematch(function(a,b) { + var amod = a.content.substr(1), + bmod = b.content.substr(1); + return Rematch.distance(amod, bmod); + }); + function generateSideBySideFileHtml(file, config) { var fileHtml = {}; fileHtml.left = ''; @@ -2145,57 +2355,80 @@ var oldLines = []; var newLines = []; - var tmpHtml = ''; + function processChangeBlock() { + var matches; + var insertType; + var deleteType; + var doMatching = config.matching === "lines" || config.matching === "words"; + if (doMatching) { + matches = matcher(oldLines, newLines); + insertType = diffParser.LINE_TYPE.INSERT_CHANGES; + deleteType = diffParser.LINE_TYPE.DELETE_CHANGES; + } else { + matches = [[oldLines,newLines]]; + insertType = diffParser.LINE_TYPE.INSERTS; + deleteType = diffParser.LINE_TYPE.DELETES; + } + matches.forEach(function(match){ + var oldLines = match[0]; + var newLines = match[1]; + var tmpHtml; + var j = 0; + var oldLine, newLine, + common = Math.min(oldLines.length, newLines.length), + max = Math.max(oldLines.length, newLines.length); + for (j = 0; j < common; j++) { + oldLine = oldLines[j]; + newLine = newLines[j]; + config.isCombined = file.isCombined; + + var diff = printerUtils.diffHighlight(oldLine.content, newLine.content, config); + + fileHtml.left += + generateSingleLineHtml(deleteType, oldLine.oldNumber, + diff.first.line, diff.first.prefix); + fileHtml.right += + generateSingleLineHtml(insertType, newLine.newNumber, + diff.second.line, diff.second.prefix); + } + if (max > common) { + var oldSlice = oldLines.slice(common), + newSlice = newLines.slice(common); + tmpHtml = processLines(oldLines.slice(common), newLines.slice(common)); + fileHtml.left += tmpHtml.left; + fileHtml.right += tmpHtml.right; + } + }); + oldLines = []; + newLines = []; + } for (var i = 0; i < block.lines.length; i++) { var line = block.lines[i]; - var escapedLine = utils.escape(line.content); + var prefix = line[0]; + var escapedLine = utils.escape(line.content.substr(1)); - if (line.type == diffParser.LINE_TYPE.CONTEXT && !oldLines.length && !newLines.length) { - fileHtml.left += generateSingleLineHtml(line.type, line.oldNumber, escapedLine); - fileHtml.right += generateSingleLineHtml(line.type, line.newNumber, escapedLine); - } else if (line.type == diffParser.LINE_TYPE.INSERTS && !oldLines.length && !newLines.length) { + if ( line.type !== diffParser.LINE_TYPE.INSERTS && + (newLines.length > 0 || (line.type !== diffParser.LINE_TYPE.DELETES && oldLines.length > 0))) { + processChangeBlock(); + } + if (line.type == diffParser.LINE_TYPE.CONTEXT) { + fileHtml.left += generateSingleLineHtml(line.type, line.oldNumber, escapedLine, prefix); + fileHtml.right += generateSingleLineHtml(line.type, line.newNumber, escapedLine, prefix); + } else if (line.type == diffParser.LINE_TYPE.INSERTS && !oldLines.length) { fileHtml.left += generateSingleLineHtml(diffParser.LINE_TYPE.CONTEXT, '', '', ''); - fileHtml.right += generateSingleLineHtml(line.type, line.newNumber, escapedLine); - } else if (line.type == diffParser.LINE_TYPE.DELETES && !newLines.length) { + fileHtml.right += generateSingleLineHtml(line.type, line.newNumber, escapedLine, prefix); + } else if (line.type == diffParser.LINE_TYPE.DELETES) { oldLines.push(line); - } else if (line.type == diffParser.LINE_TYPE.INSERTS && oldLines.length > newLines.length) { + } else if (line.type == diffParser.LINE_TYPE.INSERTS && !!oldLines.length) { newLines.push(line); } else { - var j = 0; - var oldLine, newLine; - - if (oldLines.length === newLines.length) { - for (j = 0; j < oldLines.length; j++) { - oldLine = oldLines[j]; - newLine = newLines[j]; - - config.isCombined = file.isCombined; - - var diff = printerUtils.diffHighlight(oldLine.content, newLine.content, config); - - fileHtml.left += - generateSingleLineHtml(oldLine.type, oldLine.oldNumber, - diff.first.line, diff.first.prefix); - fileHtml.right += - generateSingleLineHtml(newLine.type, newLine.newNumber, - diff.second.line, diff.second.prefix); - } - } else { - tmpHtml = processLines(oldLines, newLines); - fileHtml.left += tmpHtml.left; - fileHtml.right += tmpHtml.right; - } - - oldLines = []; - newLines = []; - i--; + console.error('unknown state in html side-by-side generator'); + processChangeBlock(); } } - tmpHtml = processLines(oldLines, newLines); - fileHtml.left += tmpHtml.left; - fileHtml.right += tmpHtml.right; + processChangeBlock(); }); return fileHtml; @@ -2210,16 +2443,27 @@ for (j = 0; j < maxLinesNumber; j++) { var oldLine = oldLines[j]; var newLine = newLines[j]; - + var oldContent; + var newContent; + var oldPrefix; + var newPrefix; + if (oldLine) { + oldContent = utils.escape(oldLine.content.substr(1)); + oldPrefix = oldLine.content[0]; + } + if (newLine) { + newContent = utils.escape(newLine.content.substr(1)); + newPrefix = newLine.content[0]; + } if (oldLine && newLine) { - fileHtml.left += generateSingleLineHtml(oldLine.type, oldLine.oldNumber, utils.escape(oldLine.content)); - fileHtml.right += generateSingleLineHtml(newLine.type, newLine.newNumber, utils.escape(newLine.content)); + fileHtml.left += generateSingleLineHtml(oldLine.type, oldLine.oldNumber, oldContent, oldPrefix); + fileHtml.right += generateSingleLineHtml(newLine.type, newLine.newNumber, newContent, newPrefix); } else if (oldLine) { - fileHtml.left += generateSingleLineHtml(oldLine.type, oldLine.oldNumber, utils.escape(oldLine.content)); + fileHtml.left += generateSingleLineHtml(oldLine.type, oldLine.oldNumber, oldContent, oldPrefix); fileHtml.right += generateSingleLineHtml(diffParser.LINE_TYPE.CONTEXT, '', '', ''); } else if (newLine) { fileHtml.left += generateSingleLineHtml(diffParser.LINE_TYPE.CONTEXT, '', '', ''); - fileHtml.right += generateSingleLineHtml(newLine.type, newLine.newNumber, utils.escape(newLine.content)); + fileHtml.right += generateSingleLineHtml(newLine.type, newLine.newNumber, newContent, newPrefix); } else { console.error('How did it get here?'); } diff --git a/dist/diff2html.min.css b/dist/diff2html.min.css index 0a81260..2981be9 100644 --- a/dist/diff2html.min.css +++ b/dist/diff2html.min.css @@ -1 +1 @@ -.d2h-wrapper{display:block;margin:0 auto;text-align:left;width:100%}.d2h-file-wrapper{border:1px solid #ddd;border-radius:3px;margin-bottom:1em}.d2h-file-header{padding:5px 10px;border-bottom:1px solid #d8d8d8;background-color:#f7f7f7;font:13px Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol"}.d2h-file-stats{display:inline;font-size:12px;text-align:center;max-width:15%}.d2h-lines-added{text-align:right}.d2h-lines-added>*{background-color:#ceffce;border:1px solid #b4e2b4;color:#399839;border-radius:5px 0 0 5px;padding:2px;width:25px}.d2h-lines-deleted{text-align:left}.d2h-lines-deleted>*{background-color:#f7c8c8;border:1px solid #e9aeae;color:#c33;border-radius:0 5px 5px 0;padding:2px;width:25px}.d2h-file-name{display:inline;height:33px;line-height:33px;max-width:80%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.d2h-diff-table{border-collapse:collapse;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;height:18px;line-height:18px;width:100%}.d2h-files-diff{width:100%}.d2h-file-diff{overflow-x:scroll;overflow-y:hidden}.d2h-file-side-diff{display:inline-block;overflow-x:scroll;overflow-y:hidden;width:50%;margin-right:-4px}.d2h-code-line{display:block;white-space:pre;padding:0 10px;height:18px;line-height:18px;margin-left:80px;color:inherit;overflow-x:inherit;background:none}.d2h-code-side-line{display:block;white-space:pre;padding:0 10px;height:18px;line-height:18px;margin-left:50px;color:inherit;overflow-x:inherit;background:none}.d2h-code-line del,.d2h-code-side-line del{display:inline-block;margin-top:-1px;text-decoration:none;background-color:#ffb6ba;border-radius:.2em}.d2h-code-line ins,.d2h-code-side-line ins{display:inline-block;margin-top:-1px;text-decoration:none;background-color:#97f295;border-radius:.2em}.d2h-code-line-prefix{float:left;background:none;padding:0}.d2h-code-line-ctn{background:none;padding:0}.line-num1{display:inline-block;float:left;width:30px;overflow:hidden;text-overflow:ellipsis}.line-num2{display:inline-block;float:right;width:30px;overflow:hidden;text-overflow:ellipsis}.d2h-code-linenumber{position:absolute;width:2%;min-width:65px;padding-left:10px;padding-right:10px;height:18px;line-height:18px;background-color:#fff;color:rgba(0,0,0,0.3);text-align:right;border:solid #eeeeee;border-width:0 1px 0 1px;cursor:pointer}.d2h-code-side-linenumber{position:absolute;width:35px;padding-left:10px;padding-right:10px;height:18px;line-height:18px;background-color:#fff;color:rgba(0,0,0,0.3);text-align:right;border:solid #eeeeee;border-width:0 1px 0 1px;cursor:pointer;overflow:hidden;text-overflow:ellipsis}.d2h-del{background-color:#fee8e9;border-color:#e9aeae}.d2h-ins{background-color:#dfd;border-color:#b4e2b4}.d2h-info{background-color:#f8fafd;color:rgba(0,0,0,0.3);border-color:#d5e4f2}.d2h-file-list-wrapper{margin-bottom:10px;padding:0 10px}.d2h-file-list-wrapper a{text-decoration:none;color:#3572b0}.d2h-file-list-wrapper a:visited{color:#3572b0}.d2h-file-list-header{font-weight:bold;margin-bottom:5px;text-align:left;display:inline;float:left}.d2h-file-list-line{text-align:left;font:13px Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol"}.d2h-file-list-line .d2h-file-name{line-height:21px}.d2h-file-list{display:none}.d2h-clear{display:block;clear:both}.d2h-show{display:none;float:left}.d2h-hide{float:left}.d2h-hide:target+.d2h-show{display:inline}.d2h-hide:target{display:none}.d2h-hide:target~.d2h-file-list{display:block} \ No newline at end of file +.d2h-wrapper{display:block;margin:0 auto;text-align:left;width:100%}.d2h-file-wrapper{border:1px solid #ddd;border-radius:3px;margin-bottom:1em}.d2h-file-header{padding:5px 10px;border-bottom:1px solid #d8d8d8;background-color:#f7f7f7;font:13px Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol"}.d2h-file-stats{display:inline;font-size:12px;text-align:center;max-width:15%}.d2h-lines-added{text-align:right}.d2h-lines-added>*{background-color:#ceffce;border:1px solid #b4e2b4;color:#399839;border-radius:5px 0 0 5px;padding:2px;width:25px}.d2h-lines-deleted{text-align:left}.d2h-lines-deleted>*{background-color:#f7c8c8;border:1px solid #e9aeae;color:#c33;border-radius:0 5px 5px 0;padding:2px;width:25px}.d2h-file-name{display:inline;height:33px;line-height:33px;max-width:80%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.d2h-diff-table{border-collapse:collapse;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;height:18px;line-height:18px;width:100%}.d2h-files-diff{width:100%}.d2h-file-diff{overflow-x:scroll;overflow-y:hidden}.d2h-file-side-diff{display:inline-block;overflow-x:scroll;overflow-y:hidden;width:50%;margin-right:-4px}.d2h-code-line{display:block;white-space:pre;padding:0 10px;height:18px;line-height:18px;margin-left:80px;color:inherit;overflow-x:inherit;background:none}.d2h-code-side-line{display:block;white-space:pre;padding:0 10px;height:18px;line-height:18px;margin-left:50px;color:inherit;overflow-x:inherit;background:none}.d2h-code-line del,.d2h-code-side-line del{display:inline-block;margin-top:-1px;text-decoration:none;background-color:#ffb6ba;border-radius:.2em}.d2h-code-line ins,.d2h-code-side-line ins{display:inline-block;margin-top:-1px;text-decoration:none;background-color:#97f295;border-radius:.2em}.d2h-code-line-prefix{float:left;background:none;padding:0}.d2h-code-line-ctn{background:none;padding:0}.line-num1{display:inline-block;float:left;width:30px;overflow:hidden;text-overflow:ellipsis}.line-num2{display:inline-block;float:right;width:30px;overflow:hidden;text-overflow:ellipsis}.d2h-code-linenumber{position:absolute;width:2%;min-width:65px;padding-left:10px;padding-right:10px;height:18px;line-height:18px;background-color:#fff;color:rgba(0,0,0,0.3);text-align:right;border:solid #eeeeee;border-width:0 1px 0 1px;cursor:pointer}.d2h-code-side-linenumber{position:absolute;width:35px;padding-left:10px;padding-right:10px;height:18px;line-height:18px;background-color:#fff;color:rgba(0,0,0,0.3);text-align:right;border:solid #eeeeee;border-width:0 1px 0 1px;cursor:pointer;overflow:hidden;text-overflow:ellipsis}.d2h-del{background-color:#fee8e9;border-color:#e9aeae}.d2h-ins{background-color:#dfd;border-color:#b4e2b4}.d2h-info{background-color:#f8fafd;color:rgba(0,0,0,0.3);border-color:#d5e4f2}.d2h-file-list-wrapper{margin-bottom:10px;padding:0 10px}.d2h-file-list-wrapper a{text-decoration:none;color:#3572b0}.d2h-file-list-wrapper a:visited{color:#3572b0}.d2h-file-list-header{font-weight:bold;margin-bottom:5px;text-align:left;display:inline;float:left}.d2h-file-list-line{text-align:left;font:13px Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol"}.d2h-file-list-line .d2h-file-name{line-height:21px}.d2h-file-list{display:none}.d2h-clear{display:block;clear:both}.d2h-del.d2h-change,.d2h-ins.d2h-change{background-color:#ffc}ins.d2h-change,del.d2h-change{background-color:#fad771}.d2h-file-diff .d2h-del.d2h-change{background-color:#fae1af}.d2h-file-diff .d2h-ins.d2h-change{background-color:#ded}.d2h-show{display:none;float:left}.d2h-hide{float:left}.d2h-hide:target+.d2h-show{display:inline}.d2h-hide:target{display:none}.d2h-hide:target~.d2h-file-list{display:block} \ No newline at end of file diff --git a/dist/diff2html.min.js b/dist/diff2html.min.js index 43d2bff..39a7aa6 100644 --- a/dist/diff2html.min.js +++ b/dist/diff2html.min.js @@ -1,2 +1,3 @@ -!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports,__webpack_require__){(function(global){!function(){function Diff2Html(){}var diffParser=__webpack_require__(1).DiffParser,fileLister=__webpack_require__(3).FileListPrinter,htmlPrinter=__webpack_require__(20).HtmlPrinter;Diff2Html.prototype.getJsonFromDiff=function(diffInput){return diffParser.generateDiffJson(diffInput)},Diff2Html.prototype.getPrettyHtml=function(diffInput,config){var configOrEmpty=config||{},diffJson=diffInput;configOrEmpty.inputFormat&&"diff"!==configOrEmpty.inputFormat||(diffJson=diffParser.generateDiffJson(diffInput));var fileList="";configOrEmpty.showFiles===!0&&(fileList=fileLister.generateFileList(diffJson,configOrEmpty));var diffOutput="";return diffOutput="side-by-side"===configOrEmpty.outputFormat?htmlPrinter.generateSideBySideJsonHtml(diffJson,configOrEmpty):htmlPrinter.generateLineByLineJsonHtml(diffJson,configOrEmpty),fileList+diffOutput},Diff2Html.prototype.getPrettyHtmlFromDiff=function(diffInput,config){var configOrEmpty=config||{};return configOrEmpty.inputFormat="diff",configOrEmpty.outputFormat="line-by-line",this.getPrettyHtml(diffInput,configOrEmpty)},Diff2Html.prototype.getPrettyHtmlFromJson=function(diffJson,config){var configOrEmpty=config||{};return configOrEmpty.inputFormat="json",configOrEmpty.outputFormat="line-by-line",this.getPrettyHtml(diffJson,configOrEmpty)},Diff2Html.prototype.getPrettySideBySideHtmlFromDiff=function(diffInput,config){var configOrEmpty=config||{};return configOrEmpty.inputFormat="diff",configOrEmpty.outputFormat="side-by-side",this.getPrettyHtml(diffInput,configOrEmpty)},Diff2Html.prototype.getPrettySideBySideHtmlFromJson=function(diffJson,config){var configOrEmpty=config||{};return configOrEmpty.inputFormat="json",configOrEmpty.outputFormat="side-by-side",this.getPrettyHtml(diffJson,configOrEmpty)};var diffName="Diff2Html",diffObject=new Diff2Html;module.exports[diffName]=diffObject,global[diffName]=diffObject}(this)}).call(exports,function(){return this}())},function(module,exports,__webpack_require__){!function(){function DiffParser(){}function getExtension(filename,language){var nameSplit=filename.split(".");return nameSplit.length>1?nameSplit[nameSplit.length-1]:language}var utils=__webpack_require__(2).Utils,LINE_TYPE={INSERTS:"d2h-ins",DELETES:"d2h-del",CONTEXT:"d2h-cntx",INFO:"d2h-info"};DiffParser.prototype.LINE_TYPE=LINE_TYPE,DiffParser.prototype.generateDiffJson=function(diffInput){var files=[],currentFile=null,currentBlock=null,oldLine=null,newLine=null,saveBlock=function(){currentBlock&&(currentFile.blocks.push(currentBlock),currentBlock=null)},saveFile=function(){currentFile&¤tFile.newName&&(files.push(currentFile),currentFile=null)},startFile=function(){saveBlock(),saveFile(),currentFile={},currentFile.blocks=[],currentFile.deletedLines=0,currentFile.addedLines=0},startBlock=function(line){saveBlock();var values;(values=/^@@ -(\d+),\d+ \+(\d+),\d+ @@.*/.exec(line))?currentFile.isCombined=!1:(values=/^@@@ -(\d+),\d+ -\d+,\d+ \+(\d+),\d+ @@@.*/.exec(line))?currentFile.isCombined=!0:(values=[0,0],currentFile.isCombined=!1),oldLine=values[1],newLine=values[2],currentBlock={},currentBlock.lines=[],currentBlock.oldStartLine=oldLine,currentBlock.newStartLine=newLine,currentBlock.header=line},createLine=function(line){var currentLine={};currentLine.content=line;var newLinePrefixes=currentFile.isCombined?["+"," +"]:["+"],delLinePrefixes=currentFile.isCombined?["-"," -"]:["-"];utils.startsWith(line,newLinePrefixes)?(currentFile.addedLines++,currentLine.type=LINE_TYPE.INSERTS,currentLine.oldNumber=null,currentLine.newNumber=newLine++,currentBlock.lines.push(currentLine)):utils.startsWith(line,delLinePrefixes)?(currentFile.deletedLines++,currentLine.type=LINE_TYPE.DELETES,currentLine.oldNumber=oldLine++,currentLine.newNumber=null,currentBlock.lines.push(currentLine)):(currentLine.type=LINE_TYPE.CONTEXT,currentLine.oldNumber=oldLine++,currentLine.newNumber=newLine++,currentBlock.lines.push(currentLine))},diffLines=diffInput.split("\n"),oldMode=/^old mode (\d{6})/,newMode=/^new mode (\d{6})/,deletedFileMode=/^deleted file mode (\d{6})/,newFileMode=/^new file mode (\d{6})/,copyFrom=/^copy from (.+)/,copyTo=/^copy to (.+)/,renameFrom=/^rename from (.+)/,renameTo=/^rename to (.+)/,similarityIndex=/^similarity index (\d+)%/,dissimilarityIndex=/^dissimilarity index (\d+)%/,index=/^index ([0-9a-z]+)..([0-9a-z]+) (\d{6})?/,combinedIndex=/^index ([0-9a-z]+),([0-9a-z]+)..([0-9a-z]+)/,combinedMode=/^mode (\d{6}),(\d{6})..(\d{6})/,combinedNewFile=/^new file mode (\d{6})/,combinedDeletedFile=/^deleted file mode (\d{6}),(\d{6})/;return diffLines.forEach(function(line){if(line&&!utils.startsWith(line,"*")){var values=[];utils.startsWith(line,"diff")?startFile():currentFile&&!currentFile.oldName&&(values=/^--- [aiwco]\/(.+)$/.exec(line))?(currentFile.oldName=values[1],currentFile.language=getExtension(currentFile.oldName,currentFile.language)):currentFile&&!currentFile.newName&&(values=/^\+\+\+ [biwco]?\/(.+)$/.exec(line))?(currentFile.newName=values[1],currentFile.language=getExtension(currentFile.newName,currentFile.language)):currentFile&&utils.startsWith(line,"@@")?startBlock(line):(values=oldMode.exec(line))?currentFile.oldMode=values[1]:(values=newMode.exec(line))?currentFile.newMode=values[1]:(values=deletedFileMode.exec(line))?currentFile.deletedFileMode=values[1]:(values=newFileMode.exec(line))?currentFile.newFileMode=values[1]:(values=copyFrom.exec(line))?(currentFile.oldName=values[1],currentFile.isCopy=!0):(values=copyTo.exec(line))?(currentFile.newName=values[1],currentFile.isCopy=!0):(values=renameFrom.exec(line))?(currentFile.oldName=values[1],currentFile.isRename=!0):(values=renameTo.exec(line))?(currentFile.newName=values[1],currentFile.isRename=!0):(values=similarityIndex.exec(line))?currentFile.unchangedPercentage=values[1]:(values=dissimilarityIndex.exec(line))?currentFile.changedPercentage=values[1]:(values=index.exec(line))?(currentFile.checksumBefore=values[1],currentFile.checksumAfter=values[2],values[2]&&(currentFile.mode=values[3])):(values=combinedIndex.exec(line))?(currentFile.checksumBefore=[values[2],values[3]],currentFile.checksumAfter=values[1]):(values=combinedMode.exec(line))?(currentFile.oldMode=[values[2],values[3]],currentFile.newMode=values[1]):(values=combinedNewFile.exec(line))?currentFile.newFileMode=values[1]:(values=combinedDeletedFile.exec(line))?currentFile.deletedFileMode=values[1]:currentBlock&&createLine(line)}}),saveBlock(),saveFile(),files},module.exports.DiffParser=new DiffParser}(this)},function(module){!function(){function Utils(){}Utils.prototype.escape=function(str){return str.slice(0).replace(/&/g,"&").replace(//g,">").replace(/\t/g," ")},Utils.prototype.getRandomId=function(prefix){return prefix+"-"+Math.random().toString(36).slice(-3)},Utils.prototype.startsWith=function(str,start){if("object"==typeof start){var result=!1;return start.forEach(function(s){0===str.indexOf(s)&&(result=!0)}),result}return 0===str.indexOf(start)},Utils.prototype.valueOrEmpty=function(value){return value?value:""},module.exports.Utils=new Utils}(this)},function(module,exports,__webpack_require__){!function(){function FileListPrinter(){}var printerUtils=__webpack_require__(4).PrinterUtils,utils=__webpack_require__(2).Utils;FileListPrinter.prototype.generateFileList=function(diffFiles){var hideId=utils.getRandomId("d2h-hide"),showId=utils.getRandomId("d2h-show");return'
\n
Files changed ('+diffFiles.length+')  
\n +\n -\n
\n \n'+diffFiles.map(function(file){return' \n \n \n \n \n"}).join("\n")+"
\n +'+file.addedLines+'\n \n -'+file.deletedLines+'\n  '+printerUtils.getDiffName(file)+"
\n"},module.exports.FileListPrinter=new FileListPrinter}(this)},function(module,exports,__webpack_require__){!function(){function PrinterUtils(){}function isDeletedName(name){return"dev/null"===name}function removeIns(line){return line.replace(/(((.|\n)*?)<\/ins>)/g,"")}function removeDel(line){return line.replace(/(((.|\n)*?)<\/del>)/g,"")}var jsDiff=__webpack_require__(5),utils=__webpack_require__(2).Utils;PrinterUtils.prototype.getHtmlId=function(file){var hashCode=function(text){var i,chr,len,hash=0;if(0==text.length)return hash;for(i=0,len=text.length;len>i;i++)chr=text.charCodeAt(i),hash=(hash<<5)-hash+chr,hash|=0;return hash};return"d2h-"+hashCode(this.getDiffName(file)).toString().slice(-6)},PrinterUtils.prototype.getDiffName=function(file){var oldFilename=file.oldName,newFilename=file.newName;return oldFilename&&newFilename&&oldFilename!==newFilename&&!isDeletedName(newFilename)?oldFilename+" -> "+newFilename:newFilename&&!isDeletedName(newFilename)?newFilename:oldFilename?oldFilename:"Unknown filename"},PrinterUtils.prototype.diffHighlight=function(diffLine1,diffLine2,config){var lineStart1,lineStart2,prefixSize=1;config.isCombined&&(prefixSize=2),lineStart1=diffLine1.substr(0,prefixSize),lineStart2=diffLine2.substr(0,prefixSize),diffLine1=diffLine1.substr(prefixSize),diffLine2=diffLine2.substr(prefixSize);var diff;diff=config.charByChar?jsDiff.diffChars(diffLine1,diffLine2):jsDiff.diffWordsWithSpace(diffLine1,diffLine2);var highlightedLine="";return diff.forEach(function(part){var elemType=part.added?"ins":part.removed?"del":null,escapedValue=utils.escape(part.value);highlightedLine+=null!==elemType?"<"+elemType+">"+escapedValue+"":escapedValue}),{first:{prefix:lineStart1,line:removeIns(highlightedLine)},second:{prefix:lineStart2,line:removeDel(highlightedLine)}}},module.exports.PrinterUtils=new PrinterUtils}(this)},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}exports.__esModule=!0;var _diffBase=__webpack_require__(6),_diffBase2=_interopRequireDefault(_diffBase),_diffCharacter=__webpack_require__(7),_diffWord=__webpack_require__(8),_diffLine=__webpack_require__(10),_diffSentence=__webpack_require__(11),_diffCss=__webpack_require__(12),_diffJson=__webpack_require__(13),_patchApply=__webpack_require__(14),_patchParse=__webpack_require__(15),_patchCreate=__webpack_require__(17),_convertDmp=__webpack_require__(18),_convertXml=__webpack_require__(19);exports.Diff=_diffBase2["default"],exports.diffChars=_diffCharacter.diffChars,exports.diffWords=_diffWord.diffWords,exports.diffWordsWithSpace=_diffWord.diffWordsWithSpace,exports.diffLines=_diffLine.diffLines,exports.diffTrimmedLines=_diffLine.diffTrimmedLines,exports.diffSentences=_diffSentence.diffSentences,exports.diffCss=_diffCss.diffCss,exports.diffJson=_diffJson.diffJson,exports.structuredPatch=_patchCreate.structuredPatch,exports.createTwoFilesPatch=_patchCreate.createTwoFilesPatch,exports.createPatch=_patchCreate.createPatch,exports.applyPatch=_patchApply.applyPatch,exports.applyPatches=_patchApply.applyPatches,exports.parsePatch=_patchParse.parsePatch,exports.convertChangesToDMP=_convertDmp.convertChangesToDMP,exports.convertChangesToXML=_convertXml.convertChangesToXML,exports.canonicalize=_diffJson.canonicalize},function(module,exports){"use strict";function Diff(){}function buildValues(diff,components,newString,oldString,useLongestToken){for(var componentPos=0,componentLen=components.length,newPos=0,oldPos=0;componentLen>componentPos;componentPos++){var component=components[componentPos];if(component.removed){if(component.value=oldString.slice(oldPos,oldPos+component.count).join(""),oldPos+=component.count,componentPos&&components[componentPos-1].added){var tmp=components[componentPos-1];components[componentPos-1]=components[componentPos],components[componentPos]=tmp}}else{if(!component.added&&useLongestToken){var value=newString.slice(newPos,newPos+component.count);value=value.map(function(value,i){var oldValue=oldString[oldPos+i];return oldValue.length>value.length?oldValue:value}),component.value=value.join("")}else component.value=newString.slice(newPos,newPos+component.count).join("");newPos+=component.count,component.added||(oldPos+=component.count)}}var lastComponent=components[componentLen-1];return(lastComponent.added||lastComponent.removed)&&diff.equals("",lastComponent.value)&&(components[componentLen-2].value+=lastComponent.value,components.pop()),components}function clonePath(path){return{newPos:path.newPos,components:path.components.slice(0)}}exports.__esModule=!0,exports["default"]=Diff,Diff.prototype={diff:function(oldString,newString){function done(value){return callback?(setTimeout(function(){callback(void 0,value)},0),!0):value}function execEditLength(){for(var diagonalPath=-1*editLength;editLength>=diagonalPath;diagonalPath+=2){var basePath=void 0,addPath=bestPath[diagonalPath-1],removePath=bestPath[diagonalPath+1],_oldPos=(removePath?removePath.newPos:0)-diagonalPath;addPath&&(bestPath[diagonalPath-1]=void 0);var canAdd=addPath&&addPath.newPos+1=0&&oldLen>_oldPos;if(canAdd||canRemove){if(!canAdd||canRemove&&addPath.newPos=newLen&&_oldPos+1>=oldLen)return done(buildValues(self,basePath.components,newString,oldString,self.useLongestToken));bestPath[diagonalPath]=basePath}else bestPath[diagonalPath]=void 0}editLength++}var options=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],callback=options.callback;"function"==typeof options&&(callback=options,options={}),this.options=options;var self=this;oldString=this.castInput(oldString),newString=this.castInput(newString),oldString=this.removeEmpty(this.tokenize(oldString)),newString=this.removeEmpty(this.tokenize(newString));var newLen=newString.length,oldLen=oldString.length,editLength=1,maxEditLength=newLen+oldLen,bestPath=[{newPos:-1,components:[]}],oldPos=this.extractCommon(bestPath[0],newString,oldString,0);if(bestPath[0].newPos+1>=newLen&&oldPos+1>=oldLen)return done([{value:newString.join(""),count:newString.length}]);if(callback)!function exec(){setTimeout(function(){return editLength>maxEditLength?callback():void(execEditLength()||exec())},0)}();else for(;maxEditLength>=editLength;){var ret=execEditLength();if(ret)return ret}},pushComponent:function(components,added,removed){var last=components[components.length-1];last&&last.added===added&&last.removed===removed?components[components.length-1]={count:last.count+1,added:added,removed:removed}:components.push({count:1,added:added,removed:removed})},extractCommon:function(basePath,newString,oldString,diagonalPath){for(var newLen=newString.length,oldLen=oldString.length,newPos=basePath.newPos,oldPos=newPos-diagonalPath,commonCount=0;newLen>newPos+1&&oldLen>oldPos+1&&this.equals(newString[newPos+1],oldString[oldPos+1]);)newPos++,oldPos++,commonCount++;return commonCount&&basePath.components.push({count:commonCount}),basePath.newPos=newPos,oldPos},equals:function(left,right){return left===right},removeEmpty:function(array){for(var ret=[],i=0;ifuzzFactor))return!1;toPos++}}return!0}var options=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof uniDiff&&(uniDiff=_parse.parsePatch(uniDiff)),Array.isArray(uniDiff)){if(uniDiff.length>1)throw new Error("applyPatch only works with a single input.");uniDiff=uniDiff[0]}for(var lines=source.split("\n"),hunks=uniDiff.hunks,compareLine=options.compareLine||function(lineNumber,line,operation,patchContent){return line===patchContent},errorCount=0,fuzzFactor=options.fuzzFactor||0,minLine=0,offset=0,removeEOFNL=void 0,addEOFNL=void 0,i=0;i=start+localOffset)return localOffset;forwardExhausted=!0}if(backwardExhausted);else{if(forwardExhausted||(wantForward=!0),start-localOffset>=minLine)return-localOffset++;backwardExhausted=!0,_again=!0}}}},module.exports=exports["default"]},function(module,exports,__webpack_require__){"use strict";function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i0?contextLines(prev.lines.slice(-options.context)):[],oldRangeStart-=curRange.length,newRangeStart-=curRange.length)}(_curRange=curRange).push.apply(_curRange,_toConsumableArray(lines.map(function(entry){return(current.added?"+":"-")+entry}))),current.added?newLine+=lines.length:oldLine+=lines.length}else{if(oldRangeStart)if(lines.length<=2*options.context&&i=diff.length-2&&lines.length<=options.context){var oldEOFNewline=/\n$/.test(oldStr),newEOFNewline=/\n$/.test(newStr);0!=lines.length||oldEOFNewline?oldEOFNewline&&newEOFNewline||curRange.push("\\ No newline at end of file"):curRange.splice(hunk.oldLines,0,"\\ No newline at end of file")}hunks.push(hunk),oldRangeStart=0,newRangeStart=0,curRange=[]}oldLine+=lines.length,newLine+=lines.length}},i=0;i"):change.removed&&ret.push(""),ret.push(escapeHTML(change.value)),change.added?ret.push(""):change.removed&&ret.push("
")}return ret.join("")}function escapeHTML(s){var n=s;return n=n.replace(/&/g,"&"),n=n.replace(//g,">"),n=n.replace(/"/g,""")}exports.__esModule=!0,exports.convertChangesToXML=convertChangesToXML},function(module,exports,__webpack_require__){!function(){function HtmlPrinter(){}var lineByLinePrinter=__webpack_require__(21).LineByLinePrinter,sideBySidePrinter=__webpack_require__(22).SideBySidePrinter;HtmlPrinter.prototype.generateLineByLineJsonHtml=lineByLinePrinter.generateLineByLineJsonHtml,HtmlPrinter.prototype.generateSideBySideJsonHtml=sideBySidePrinter.generateSideBySideJsonHtml,module.exports.HtmlPrinter=new HtmlPrinter}(this)},function(module,exports,__webpack_require__){!function(){function LineByLinePrinter(){}function generateFileHtml(file,config){return file.blocks.map(function(block){ -for(var lines='\n \n
'+utils.escape(block.header)+"
\n\n",oldLines=[],newLines=[],processedOldLines=[],processedNewLines=[],i=0;inewLines.length)newLines.push(line);else{var oldLine,newLine,j=0;if(oldLines.length===newLines.length){for(j=0;j");var htmlContent="";return content&&(htmlContent=''+content+""),'\n
'+utils.valueOrEmpty(oldNumber)+'
'+utils.valueOrEmpty(newNumber)+'
\n
'+htmlPrefix+htmlContent+"
\n\n"}function generateEmptyDiff(){return'\n
File without changes
\n\n'}var diffParser=__webpack_require__(1).DiffParser,printerUtils=__webpack_require__(4).PrinterUtils,utils=__webpack_require__(2).Utils;LineByLinePrinter.prototype.generateLineByLineJsonHtml=function(diffFiles,config){return'
\n'+diffFiles.map(function(file){var diffs;return diffs=file.blocks.length?generateFileHtml(file,config):generateEmptyDiff(),'
\n
\n
\n +'+file.addedLines+'\n \n -'+file.deletedLines+'\n \n
\n
'+printerUtils.getDiffName(file)+'
\n
\n
\n
\n \n \n '+diffs+" \n
\n
\n
\n
\n"}).join("\n")+"
\n"},module.exports.LineByLinePrinter=new LineByLinePrinter}(this)},function(module,exports,__webpack_require__){!function(){function SideBySidePrinter(){}function generateSideBySideFileHtml(file,config){var fileHtml={};return fileHtml.left="",fileHtml.right="",file.blocks.forEach(function(block){fileHtml.left+='\n \n
'+utils.escape(block.header)+"
\n\n",fileHtml.right+='\n \n
\n\n';for(var oldLines=[],newLines=[],tmpHtml="",i=0;inewLines.length)newLines.push(line);else{var oldLine,newLine,j=0;if(oldLines.length===newLines.length)for(j=0;j");var htmlContent="";return content&&(htmlContent=''+content+""),'\n '+number+'\n
'+htmlPrefix+htmlContent+"
\n \n"}function generateEmptyDiff(){var fileHtml={};return fileHtml.right="",fileHtml.left='\n
File without changes
\n\n',fileHtml}var diffParser=__webpack_require__(1).DiffParser,printerUtils=__webpack_require__(4).PrinterUtils,utils=__webpack_require__(2).Utils;SideBySidePrinter.prototype.generateSideBySideJsonHtml=function(diffFiles,config){return'
\n'+diffFiles.map(function(file){var diffs;return diffs=file.blocks.length?generateSideBySideFileHtml(file,config):generateEmptyDiff(),'
\n
\n
\n +'+file.addedLines+'\n \n -'+file.deletedLines+'\n \n
\n
'+printerUtils.getDiffName(file)+'
\n
\n
\n
\n
\n \n \n '+diffs.left+' \n
\n
\n
\n
\n
\n \n \n '+diffs.right+" \n
\n
\n
\n
\n
\n"}).join("\n")+"
\n"},module.exports.SideBySidePrinter=new SideBySidePrinter}(this)}]); \ No newline at end of file +!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([function(module,exports,__webpack_require__){(function(global){!function(){function Diff2Html(){}var diffParser=__webpack_require__(1).DiffParser,fileLister=__webpack_require__(3).FileListPrinter,htmlPrinter=__webpack_require__(21).HtmlPrinter;Diff2Html.prototype.getJsonFromDiff=function(diffInput){return diffParser.generateDiffJson(diffInput)},Diff2Html.prototype.getPrettyHtml=function(diffInput,config){var configOrEmpty=config||{},diffJson=diffInput;configOrEmpty.inputFormat&&"diff"!==configOrEmpty.inputFormat||(diffJson=diffParser.generateDiffJson(diffInput));var fileList="";configOrEmpty.showFiles===!0&&(fileList=fileLister.generateFileList(diffJson,configOrEmpty));var diffOutput="";return diffOutput="side-by-side"===configOrEmpty.outputFormat?htmlPrinter.generateSideBySideJsonHtml(diffJson,configOrEmpty):htmlPrinter.generateLineByLineJsonHtml(diffJson,configOrEmpty),fileList+diffOutput},Diff2Html.prototype.getPrettyHtmlFromDiff=function(diffInput,config){var configOrEmpty=config||{};return configOrEmpty.inputFormat="diff",configOrEmpty.outputFormat="line-by-line",this.getPrettyHtml(diffInput,configOrEmpty)},Diff2Html.prototype.getPrettyHtmlFromJson=function(diffJson,config){var configOrEmpty=config||{};return configOrEmpty.inputFormat="json",configOrEmpty.outputFormat="line-by-line",this.getPrettyHtml(diffJson,configOrEmpty)},Diff2Html.prototype.getPrettySideBySideHtmlFromDiff=function(diffInput,config){var configOrEmpty=config||{};return configOrEmpty.inputFormat="diff",configOrEmpty.outputFormat="side-by-side",this.getPrettyHtml(diffInput,configOrEmpty)},Diff2Html.prototype.getPrettySideBySideHtmlFromJson=function(diffJson,config){var configOrEmpty=config||{};return configOrEmpty.inputFormat="json",configOrEmpty.outputFormat="side-by-side",this.getPrettyHtml(diffJson,configOrEmpty)};var diffName="Diff2Html",diffObject=new Diff2Html;module.exports[diffName]=diffObject,global[diffName]=diffObject}(this)}).call(exports,function(){return this}())},function(module,exports,__webpack_require__){!function(){function DiffParser(){}function getExtension(filename,language){var nameSplit=filename.split(".");return nameSplit.length>1?nameSplit[nameSplit.length-1]:language}var utils=__webpack_require__(2).Utils,LINE_TYPE={INSERTS:"d2h-ins",DELETES:"d2h-del",INSERT_CHANGES:"d2h-ins d2h-change",DELETE_CHANGES:"d2h-del d2h-change",CONTEXT:"d2h-cntx",INFO:"d2h-info"};DiffParser.prototype.LINE_TYPE=LINE_TYPE,DiffParser.prototype.generateDiffJson=function(diffInput){var files=[],currentFile=null,currentBlock=null,oldLine=null,newLine=null,saveBlock=function(){currentBlock&&(currentFile.blocks.push(currentBlock),currentBlock=null)},saveFile=function(){currentFile&¤tFile.newName&&(files.push(currentFile),currentFile=null)},startFile=function(){saveBlock(),saveFile(),currentFile={},currentFile.blocks=[],currentFile.deletedLines=0,currentFile.addedLines=0},startBlock=function(line){saveBlock();var values;(values=/^@@ -(\d+),\d+ \+(\d+),\d+ @@.*/.exec(line))?currentFile.isCombined=!1:(values=/^@@@ -(\d+),\d+ -\d+,\d+ \+(\d+),\d+ @@@.*/.exec(line))?currentFile.isCombined=!0:(values=[0,0],currentFile.isCombined=!1),oldLine=values[1],newLine=values[2],currentBlock={},currentBlock.lines=[],currentBlock.oldStartLine=oldLine,currentBlock.newStartLine=newLine,currentBlock.header=line},createLine=function(line){var currentLine={};currentLine.content=line;var newLinePrefixes=currentFile.isCombined?["+"," +"]:["+"],delLinePrefixes=currentFile.isCombined?["-"," -"]:["-"];utils.startsWith(line,newLinePrefixes)?(currentFile.addedLines++,currentLine.type=LINE_TYPE.INSERTS,currentLine.oldNumber=null,currentLine.newNumber=newLine++,currentBlock.lines.push(currentLine)):utils.startsWith(line,delLinePrefixes)?(currentFile.deletedLines++,currentLine.type=LINE_TYPE.DELETES,currentLine.oldNumber=oldLine++,currentLine.newNumber=null,currentBlock.lines.push(currentLine)):(currentLine.type=LINE_TYPE.CONTEXT,currentLine.oldNumber=oldLine++,currentLine.newNumber=newLine++,currentBlock.lines.push(currentLine))},diffLines=diffInput.split("\n"),oldMode=/^old mode (\d{6})/,newMode=/^new mode (\d{6})/,deletedFileMode=/^deleted file mode (\d{6})/,newFileMode=/^new file mode (\d{6})/,copyFrom=/^copy from (.+)/,copyTo=/^copy to (.+)/,renameFrom=/^rename from (.+)/,renameTo=/^rename to (.+)/,similarityIndex=/^similarity index (\d+)%/,dissimilarityIndex=/^dissimilarity index (\d+)%/,index=/^index ([0-9a-z]+)..([0-9a-z]+) (\d{6})?/,combinedIndex=/^index ([0-9a-z]+),([0-9a-z]+)..([0-9a-z]+)/,combinedMode=/^mode (\d{6}),(\d{6})..(\d{6})/,combinedNewFile=/^new file mode (\d{6})/,combinedDeletedFile=/^deleted file mode (\d{6}),(\d{6})/;return diffLines.forEach(function(line){if(line&&!utils.startsWith(line,"*")){var values=[];utils.startsWith(line,"diff")?startFile():currentFile&&!currentFile.oldName&&(values=/^--- [aiwco]\/(.+)$/.exec(line))?(currentFile.oldName=values[1],currentFile.language=getExtension(currentFile.oldName,currentFile.language)):currentFile&&!currentFile.newName&&(values=/^\+\+\+ [biwco]?\/(.+)$/.exec(line))?(currentFile.newName=values[1],currentFile.language=getExtension(currentFile.newName,currentFile.language)):currentFile&&utils.startsWith(line,"@@")?startBlock(line):(values=oldMode.exec(line))?currentFile.oldMode=values[1]:(values=newMode.exec(line))?currentFile.newMode=values[1]:(values=deletedFileMode.exec(line))?currentFile.deletedFileMode=values[1]:(values=newFileMode.exec(line))?currentFile.newFileMode=values[1]:(values=copyFrom.exec(line))?(currentFile.oldName=values[1],currentFile.isCopy=!0):(values=copyTo.exec(line))?(currentFile.newName=values[1],currentFile.isCopy=!0):(values=renameFrom.exec(line))?(currentFile.oldName=values[1],currentFile.isRename=!0):(values=renameTo.exec(line))?(currentFile.newName=values[1],currentFile.isRename=!0):(values=similarityIndex.exec(line))?currentFile.unchangedPercentage=values[1]:(values=dissimilarityIndex.exec(line))?currentFile.changedPercentage=values[1]:(values=index.exec(line))?(currentFile.checksumBefore=values[1],currentFile.checksumAfter=values[2],values[2]&&(currentFile.mode=values[3])):(values=combinedIndex.exec(line))?(currentFile.checksumBefore=[values[2],values[3]],currentFile.checksumAfter=values[1]):(values=combinedMode.exec(line))?(currentFile.oldMode=[values[2],values[3]],currentFile.newMode=values[1]):(values=combinedNewFile.exec(line))?currentFile.newFileMode=values[1]:(values=combinedDeletedFile.exec(line))?currentFile.deletedFileMode=values[1]:currentBlock&&createLine(line)}}),saveBlock(),saveFile(),files},module.exports.DiffParser=new DiffParser}(this)},function(module){!function(){function Utils(){}Utils.prototype.escape=function(str){return str.slice(0).replace(/&/g,"&").replace(//g,">").replace(/\t/g," ")},Utils.prototype.getRandomId=function(prefix){return prefix+"-"+Math.random().toString(36).slice(-3)},Utils.prototype.startsWith=function(str,start){if("object"==typeof start){var result=!1;return start.forEach(function(s){0===str.indexOf(s)&&(result=!0)}),result}return 0===str.indexOf(start)},Utils.prototype.valueOrEmpty=function(value){return value?value:""},module.exports.Utils=new Utils}(this)},function(module,exports,__webpack_require__){!function(){function FileListPrinter(){}var printerUtils=__webpack_require__(4).PrinterUtils,utils=__webpack_require__(2).Utils;FileListPrinter.prototype.generateFileList=function(diffFiles){var hideId=utils.getRandomId("d2h-hide"),showId=utils.getRandomId("d2h-show");return'
\n
Files changed ('+diffFiles.length+')  
\n +\n -\n
\n \n'+diffFiles.map(function(file){return' \n \n \n \n \n"}).join("\n")+"
\n +'+file.addedLines+'\n \n -'+file.deletedLines+'\n  '+printerUtils.getDiffName(file)+"
\n"},module.exports.FileListPrinter=new FileListPrinter}(this)},function(module,exports,__webpack_require__){!function(){function PrinterUtils(){}function isDeletedName(name){return"dev/null"===name}function removeIns(line){return line.replace(/(]*>((.|\n)*?)<\/ins>)/g,"")}function removeDel(line){return line.replace(/(]*>((.|\n)*?)<\/del>)/g,"")}var jsDiff=__webpack_require__(5),utils=__webpack_require__(2).Utils,Rematch=__webpack_require__(20).Rematch;PrinterUtils.prototype.getHtmlId=function(file){var hashCode=function(text){var i,chr,len,hash=0;if(0==text.length)return hash;for(i=0,len=text.length;len>i;i++)chr=text.charCodeAt(i),hash=(hash<<5)-hash+chr,hash|=0;return hash};return"d2h-"+hashCode(this.getDiffName(file)).toString().slice(-6)},PrinterUtils.prototype.getDiffName=function(file){var oldFilename=file.oldName,newFilename=file.newName;return oldFilename&&newFilename&&oldFilename!==newFilename&&!isDeletedName(newFilename)?oldFilename+" -> "+newFilename:newFilename&&!isDeletedName(newFilename)?newFilename:oldFilename?oldFilename:"Unknown filename"},PrinterUtils.prototype.diffHighlight=function(diffLine1,diffLine2,config){var lineStart1,lineStart2,prefixSize=1;config.isCombined&&(prefixSize=2),lineStart1=diffLine1.substr(0,prefixSize),lineStart2=diffLine2.substr(0,prefixSize),diffLine1=diffLine1.substr(prefixSize),diffLine2=diffLine2.substr(prefixSize);var diff;diff=config.charByChar?jsDiff.diffChars(diffLine1,diffLine2):jsDiff.diffWordsWithSpace(diffLine1,diffLine2);var highlightedLine="",changedWords=[];if(!config.charByChar&&"words"===config.matching){var treshold=.25;"undefined"!=typeof config.matchWordsThreshold&&(treshold=config.matchWordsThreshold);var matcher=Rematch.rematch(function(a,b){var amod=a.value,bmod=b.value,result=Rematch.distance(amod,bmod);return result}),removed=diff.filter(function(element){return element.removed}),added=diff.filter(function(element){return element.added}),chunks=matcher(added,removed);chunks=chunks.forEach(function(chunk){if(1===chunk[0].length&&1===chunk[1].length){var dist=Rematch.distance(chunk[0][0].value,chunk[1][0].value);treshold>dist&&(changedWords.push(chunk[0][0]),changedWords.push(chunk[1][0]))}})}return diff.forEach(function(part){var addClass=changedWords.indexOf(part)>-1?' class="d2h-change"':"",elemType=part.added?"ins":part.removed?"del":null,escapedValue=utils.escape(part.value);highlightedLine+=null!==elemType?"<"+elemType+addClass+">"+escapedValue+"":escapedValue}),{first:{prefix:lineStart1,line:removeIns(highlightedLine)},second:{prefix:lineStart2,line:removeDel(highlightedLine)}}},module.exports.PrinterUtils=new PrinterUtils}(this)},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}exports.__esModule=!0;var _diffBase=__webpack_require__(6),_diffBase2=_interopRequireDefault(_diffBase),_diffCharacter=__webpack_require__(7),_diffWord=__webpack_require__(8),_diffLine=__webpack_require__(10),_diffSentence=__webpack_require__(11),_diffCss=__webpack_require__(12),_diffJson=__webpack_require__(13),_patchApply=__webpack_require__(14),_patchParse=__webpack_require__(15),_patchCreate=__webpack_require__(17),_convertDmp=__webpack_require__(18),_convertXml=__webpack_require__(19);exports.Diff=_diffBase2["default"],exports.diffChars=_diffCharacter.diffChars,exports.diffWords=_diffWord.diffWords,exports.diffWordsWithSpace=_diffWord.diffWordsWithSpace,exports.diffLines=_diffLine.diffLines,exports.diffTrimmedLines=_diffLine.diffTrimmedLines,exports.diffSentences=_diffSentence.diffSentences,exports.diffCss=_diffCss.diffCss,exports.diffJson=_diffJson.diffJson,exports.structuredPatch=_patchCreate.structuredPatch,exports.createTwoFilesPatch=_patchCreate.createTwoFilesPatch,exports.createPatch=_patchCreate.createPatch,exports.applyPatch=_patchApply.applyPatch,exports.applyPatches=_patchApply.applyPatches,exports.parsePatch=_patchParse.parsePatch,exports.convertChangesToDMP=_convertDmp.convertChangesToDMP,exports.convertChangesToXML=_convertXml.convertChangesToXML,exports.canonicalize=_diffJson.canonicalize},function(module,exports){"use strict";function Diff(){}function buildValues(diff,components,newString,oldString,useLongestToken){for(var componentPos=0,componentLen=components.length,newPos=0,oldPos=0;componentLen>componentPos;componentPos++){var component=components[componentPos];if(component.removed){if(component.value=oldString.slice(oldPos,oldPos+component.count).join(""),oldPos+=component.count,componentPos&&components[componentPos-1].added){var tmp=components[componentPos-1];components[componentPos-1]=components[componentPos],components[componentPos]=tmp}}else{if(!component.added&&useLongestToken){var value=newString.slice(newPos,newPos+component.count);value=value.map(function(value,i){var oldValue=oldString[oldPos+i];return oldValue.length>value.length?oldValue:value}),component.value=value.join("")}else component.value=newString.slice(newPos,newPos+component.count).join("");newPos+=component.count,component.added||(oldPos+=component.count)}}var lastComponent=components[componentLen-1];return(lastComponent.added||lastComponent.removed)&&diff.equals("",lastComponent.value)&&(components[componentLen-2].value+=lastComponent.value,components.pop()),components}function clonePath(path){return{newPos:path.newPos,components:path.components.slice(0)}}exports.__esModule=!0,exports["default"]=Diff,Diff.prototype={diff:function(oldString,newString){function done(value){return callback?(setTimeout(function(){callback(void 0,value)},0),!0):value}function execEditLength(){for(var diagonalPath=-1*editLength;editLength>=diagonalPath;diagonalPath+=2){var basePath=void 0,addPath=bestPath[diagonalPath-1],removePath=bestPath[diagonalPath+1],_oldPos=(removePath?removePath.newPos:0)-diagonalPath;addPath&&(bestPath[diagonalPath-1]=void 0);var canAdd=addPath&&addPath.newPos+1=0&&oldLen>_oldPos;if(canAdd||canRemove){if(!canAdd||canRemove&&addPath.newPos=newLen&&_oldPos+1>=oldLen)return done(buildValues(self,basePath.components,newString,oldString,self.useLongestToken));bestPath[diagonalPath]=basePath}else bestPath[diagonalPath]=void 0}editLength++}var options=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],callback=options.callback;"function"==typeof options&&(callback=options,options={}),this.options=options;var self=this;oldString=this.castInput(oldString),newString=this.castInput(newString),oldString=this.removeEmpty(this.tokenize(oldString)),newString=this.removeEmpty(this.tokenize(newString));var newLen=newString.length,oldLen=oldString.length,editLength=1,maxEditLength=newLen+oldLen,bestPath=[{newPos:-1,components:[]}],oldPos=this.extractCommon(bestPath[0],newString,oldString,0);if(bestPath[0].newPos+1>=newLen&&oldPos+1>=oldLen)return done([{value:newString.join(""),count:newString.length}]);if(callback)!function exec(){setTimeout(function(){return editLength>maxEditLength?callback():void(execEditLength()||exec())},0)}();else for(;maxEditLength>=editLength;){var ret=execEditLength();if(ret)return ret}},pushComponent:function(components,added,removed){var last=components[components.length-1];last&&last.added===added&&last.removed===removed?components[components.length-1]={count:last.count+1,added:added,removed:removed}:components.push({count:1,added:added,removed:removed})},extractCommon:function(basePath,newString,oldString,diagonalPath){for(var newLen=newString.length,oldLen=oldString.length,newPos=basePath.newPos,oldPos=newPos-diagonalPath,commonCount=0;newLen>newPos+1&&oldLen>oldPos+1&&this.equals(newString[newPos+1],oldString[oldPos+1]);)newPos++,oldPos++,commonCount++;return commonCount&&basePath.components.push({count:commonCount}),basePath.newPos=newPos,oldPos},equals:function(left,right){return left===right},removeEmpty:function(array){for(var ret=[],i=0;ifuzzFactor))return!1;toPos++}}return!0}var options=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof uniDiff&&(uniDiff=_parse.parsePatch(uniDiff)),Array.isArray(uniDiff)){if(uniDiff.length>1)throw new Error("applyPatch only works with a single input.");uniDiff=uniDiff[0]}for(var lines=source.split("\n"),hunks=uniDiff.hunks,compareLine=options.compareLine||function(lineNumber,line,operation,patchContent){return line===patchContent},errorCount=0,fuzzFactor=options.fuzzFactor||0,minLine=0,offset=0,removeEOFNL=void 0,addEOFNL=void 0,i=0;i=start+localOffset)return localOffset;forwardExhausted=!0}if(backwardExhausted);else{if(forwardExhausted||(wantForward=!0),start-localOffset>=minLine)return-localOffset++;backwardExhausted=!0,_again=!0}}}},module.exports=exports["default"]},function(module,exports,__webpack_require__){"use strict";function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i0?contextLines(prev.lines.slice(-options.context)):[],oldRangeStart-=curRange.length,newRangeStart-=curRange.length)}(_curRange=curRange).push.apply(_curRange,_toConsumableArray(lines.map(function(entry){return(current.added?"+":"-")+entry}))),current.added?newLine+=lines.length:oldLine+=lines.length}else{if(oldRangeStart)if(lines.length<=2*options.context&&i=diff.length-2&&lines.length<=options.context){var oldEOFNewline=/\n$/.test(oldStr),newEOFNewline=/\n$/.test(newStr);0!=lines.length||oldEOFNewline?oldEOFNewline&&newEOFNewline||curRange.push("\\ No newline at end of file"):curRange.splice(hunk.oldLines,0,"\\ No newline at end of file")}hunks.push(hunk),oldRangeStart=0,newRangeStart=0,curRange=[]}oldLine+=lines.length,newLine+=lines.length}},i=0;i"):change.removed&&ret.push(""),ret.push(escapeHTML(change.value)),change.added?ret.push("
"):change.removed&&ret.push(""); + +}return ret.join("")}function escapeHTML(s){var n=s;return n=n.replace(/&/g,"&"),n=n.replace(//g,">"),n=n.replace(/"/g,""")}exports.__esModule=!0,exports.convertChangesToXML=convertChangesToXML},function(module){!function(){function levenshtein(a,b){if(0==a.length)return b.length;if(0==b.length)return a.length;var i,matrix=[];for(i=0;i<=b.length;i++)matrix[i]=[i];var j;for(j=0;j<=a.length;j++)matrix[0][j]=j;for(i=1;i<=b.length;i++)for(j=1;j<=a.length;j++)matrix[i][j]=b.charAt(i-1)==a.charAt(j-1)?matrix[i-1][j-1]:Math.min(matrix[i-1][j-1]+1,Math.min(matrix[i][j-1]+1,matrix[i-1][j]+1));return matrix[b.length][a.length]}var Rematch={};Rematch.arrayToString=function arrayToString(a){return"[object Array]"===Object.prototype.toString.apply(a,[])?"["+a.map(arrayToString).join(", ")+"]":a},Rematch.levenshtein=levenshtein,Rematch.distance=function(x,y){x=x.trim(),y=y.trim();var lev=levenshtein(x,y),score=lev/(x.length+y.length);return score},Rematch.rematch=function(distanceFunction){function findBestMatch(a,b,cache){var cachecount=0;for(var key in cache)cachecount++;for(var bestMatch,bestMatchDist=1/0,i=0;imd&&(bestMatchDist=md,bestMatch={indexA:i,indexB:j,score:bestMatchDist})}return bestMatch}function group(a,b,level,cache){"undefined"==typeof cache&&(cache={});var bm=(Math.min(a.length,b.length),findBestMatch(a,b,cache));if(level||(level=0),!bm||a.length+b.length<3)return[[a,b]];var a1=a.slice(0,bm.indexA),b1=b.slice(0,bm.indexB),aMatch=[a[bm.indexA]],bMatch=[b[bm.indexB]],tailA=bm.indexA+1,tailB=bm.indexB+1,a2=a.slice(tailA),b2=b.slice(tailB),group1=group(a1,b1,level+1,cache),groupMatch=group(aMatch,bMatch,level+1,cache),group2=group(a2,b2,level+1,cache),result=groupMatch;return(bm.indexA>0||bm.indexB>0)&&(result=group1.concat(result)),(a.length>tailA||b.length>tailB)&&(result=result.concat(group2)),result}return group},module.exports.Rematch=Rematch}(this)},function(module,exports,__webpack_require__){!function(){function HtmlPrinter(){}var lineByLinePrinter=__webpack_require__(22).LineByLinePrinter,sideBySidePrinter=__webpack_require__(23).SideBySidePrinter;HtmlPrinter.prototype.generateLineByLineJsonHtml=lineByLinePrinter.generateLineByLineJsonHtml,HtmlPrinter.prototype.generateSideBySideJsonHtml=sideBySidePrinter.generateSideBySideJsonHtml,module.exports.HtmlPrinter=new HtmlPrinter}(this)},function(module,exports,__webpack_require__){!function(){function LineByLinePrinter(){}function generateFileHtml(file,config){return file.blocks.map(function(block){function processChangeBlock(){var matches,insertType,deleteType,doMatching="lines"===config.matching||"words"===config.matching;doMatching?(matches=matcher(oldLines,newLines),insertType=diffParser.LINE_TYPE.INSERT_CHANGES,deleteType=diffParser.LINE_TYPE.DELETE_CHANGES):(matches=[[oldLines,newLines]],insertType=diffParser.LINE_TYPE.INSERTS,deleteType=diffParser.LINE_TYPE.DELETES),matches.forEach(function(match){{var oldLine,newLine,oldLines=match[0],newLines=match[1],processedOldLines=[],processedNewLines=[],j=0,common=Math.min(oldLines.length,newLines.length);Math.max(oldLines.length,newLines.length)}for(j=0;common>j;j++){oldLine=oldLines[j],newLine=newLines[j],config.isCombined=file.isCombined;var diff=printerUtils.diffHighlight(oldLine.content,newLine.content,config);processedOldLines+=generateLineHtml(deleteType,oldLine.oldNumber,oldLine.newNumber,diff.first.line,diff.first.prefix),processedNewLines+=generateLineHtml(insertType,newLine.oldNumber,newLine.newNumber,diff.second.line,diff.second.prefix)}lines+=processedOldLines+processedNewLines,lines+=processLines(oldLines.slice(common),newLines.slice(common)),processedOldLines=[],processedNewLines=[]}),oldLines=[],newLines=[]}for(var lines='\n \n
'+utils.escape(block.header)+"
\n\n",oldLines=[],newLines=[],i=0;i0||line.type!==diffParser.LINE_TYPE.DELETES&&oldLines.length>0)&&processChangeBlock(),line.type==diffParser.LINE_TYPE.CONTEXT?lines+=generateLineHtml(line.type,line.oldNumber,line.newNumber,escapedLine):line.type!=diffParser.LINE_TYPE.INSERTS||oldLines.length?line.type==diffParser.LINE_TYPE.DELETES?oldLines.push(line):line.type==diffParser.LINE_TYPE.INSERTS&&oldLines.length?newLines.push(line):(console.error("unknown state in html line-by-line generator"),processChangeBlock()):lines+=generateLineHtml(line.type,line.oldNumber,line.newNumber,escapedLine)}return processChangeBlock(),lines}).join("\n")}function processLines(oldLines,newLines){var lines="";for(j=0;j");var htmlContent="";return content&&(htmlContent=''+content+""),'\n
'+utils.valueOrEmpty(oldNumber)+'
'+utils.valueOrEmpty(newNumber)+'
\n
'+htmlPrefix+htmlContent+"
\n\n"}function generateEmptyDiff(){return'\n
File without changes
\n\n'}var diffParser=__webpack_require__(1).DiffParser,printerUtils=__webpack_require__(4).PrinterUtils,utils=__webpack_require__(2).Utils,Rematch=__webpack_require__(20).Rematch;LineByLinePrinter.prototype.generateLineByLineJsonHtml=function(diffFiles,config){return'
\n'+diffFiles.map(function(file){var diffs;return diffs=file.blocks.length?generateFileHtml(file,config):generateEmptyDiff(),'
\n
\n
\n +'+file.addedLines+'\n \n -'+file.deletedLines+'\n \n
\n
'+printerUtils.getDiffName(file)+'
\n
\n
\n
\n \n \n '+diffs+" \n
\n
\n
\n
\n"}).join("\n")+"
\n"};var matcher=Rematch.rematch(function(a,b){var amod=a.content.substr(1),bmod=b.content.substr(1);return Rematch.distance(amod,bmod)});module.exports.LineByLinePrinter=new LineByLinePrinter}(this)},function(module,exports,__webpack_require__){!function(){function SideBySidePrinter(){}function generateSideBySideFileHtml(file,config){var fileHtml={};return fileHtml.left="",fileHtml.right="",file.blocks.forEach(function(block){function processChangeBlock(){var matches,insertType,deleteType,doMatching="lines"===config.matching||"words"===config.matching;doMatching?(matches=matcher(oldLines,newLines),insertType=diffParser.LINE_TYPE.INSERT_CHANGES,deleteType=diffParser.LINE_TYPE.DELETE_CHANGES):(matches=[[oldLines,newLines]],insertType=diffParser.LINE_TYPE.INSERTS,deleteType=diffParser.LINE_TYPE.DELETES),matches.forEach(function(match){var tmpHtml,oldLine,newLine,oldLines=match[0],newLines=match[1],j=0,common=Math.min(oldLines.length,newLines.length),max=Math.max(oldLines.length,newLines.length);for(j=0;common>j;j++){oldLine=oldLines[j],newLine=newLines[j],config.isCombined=file.isCombined;var diff=printerUtils.diffHighlight(oldLine.content,newLine.content,config);fileHtml.left+=generateSingleLineHtml(deleteType,oldLine.oldNumber,diff.first.line,diff.first.prefix),fileHtml.right+=generateSingleLineHtml(insertType,newLine.newNumber,diff.second.line,diff.second.prefix)}if(max>common){{oldLines.slice(common),newLines.slice(common)}tmpHtml=processLines(oldLines.slice(common),newLines.slice(common)),fileHtml.left+=tmpHtml.left,fileHtml.right+=tmpHtml.right}}),oldLines=[],newLines=[]}fileHtml.left+='\n \n
'+utils.escape(block.header)+"
\n\n",fileHtml.right+='\n \n
\n\n';for(var oldLines=[],newLines=[],i=0;i0||line.type!==diffParser.LINE_TYPE.DELETES&&oldLines.length>0)&&processChangeBlock(),line.type==diffParser.LINE_TYPE.CONTEXT?(fileHtml.left+=generateSingleLineHtml(line.type,line.oldNumber,escapedLine,prefix),fileHtml.right+=generateSingleLineHtml(line.type,line.newNumber,escapedLine,prefix)):line.type!=diffParser.LINE_TYPE.INSERTS||oldLines.length?line.type==diffParser.LINE_TYPE.DELETES?oldLines.push(line):line.type==diffParser.LINE_TYPE.INSERTS&&oldLines.length?newLines.push(line):(console.error("unknown state in html side-by-side generator"),processChangeBlock()):(fileHtml.left+=generateSingleLineHtml(diffParser.LINE_TYPE.CONTEXT,"","",""),fileHtml.right+=generateSingleLineHtml(line.type,line.newNumber,escapedLine,prefix))}processChangeBlock()}),fileHtml}function processLines(oldLines,newLines){var fileHtml={};fileHtml.left="",fileHtml.right="";var maxLinesNumber=Math.max(oldLines.length,newLines.length);for(j=0;j");var htmlContent="";return content&&(htmlContent=''+content+""),'\n '+number+'\n
'+htmlPrefix+htmlContent+"
\n \n"}function generateEmptyDiff(){var fileHtml={};return fileHtml.right="",fileHtml.left='\n
File without changes
\n\n',fileHtml}var diffParser=__webpack_require__(1).DiffParser,printerUtils=__webpack_require__(4).PrinterUtils,utils=__webpack_require__(2).Utils,Rematch=__webpack_require__(20).Rematch;SideBySidePrinter.prototype.generateSideBySideJsonHtml=function(diffFiles,config){return'
\n'+diffFiles.map(function(file){var diffs;return diffs=file.blocks.length?generateSideBySideFileHtml(file,config):generateEmptyDiff(),'
\n
\n
\n +'+file.addedLines+'\n \n -'+file.deletedLines+'\n \n
\n
'+printerUtils.getDiffName(file)+'
\n
\n
\n
\n
\n \n \n '+diffs.left+' \n
\n
\n
\n
\n
\n \n \n '+diffs.right+" \n
\n
\n
\n
\n
\n"}).join("\n")+"
\n"};var matcher=Rematch.rematch(function(a,b){var amod=a.content.substr(1),bmod=b.content.substr(1);return Rematch.distance(amod,bmod)});module.exports.SideBySidePrinter=new SideBySidePrinter}(this)}]); \ No newline at end of file diff --git a/package.json b/package.json index a759690..0343608 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "diff2html", - "version": "1.1.3", + "version": "1.2.0", "homepage": "http://rtfpessoa.github.io/diff2html/", "description": "Fast Diff to colorized HTML", "keywords": [