diff2html
Advanced tools
Comparing version 2.0.0-rc.8 to 2.0.0-rc.9
@@ -16,7 +16,6 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
(function() { | ||
var highlightJS = require('./highlight.js-internals.js').HighlightJS; | ||
var diffJson = null; | ||
var defaultTarget = "body"; | ||
var defaultTarget = 'body'; | ||
var currentSelectionColumnId = -1; | ||
@@ -46,9 +45,7 @@ | ||
if (config.synchronisedScroll) { | ||
$target.find(".d2h-file-side-diff").scroll(function() { | ||
$target.find('.d2h-file-side-diff').scroll(function() { | ||
var $this = $(this); | ||
$this.closest(".d2h-file-wrapper").find(".d2h-file-side-diff") | ||
$this.closest('.d2h-file-wrapper').find('.d2h-file-side-diff') | ||
.scrollLeft($this.scrollLeft()); | ||
}); | ||
} | ||
@@ -62,5 +59,5 @@ } | ||
var $showBtn = $target.find(".d2h-show"); | ||
var $hideBtn = $target.find(".d2h-hide"); | ||
var $fileList = $target.find(".d2h-file-list"); | ||
var $showBtn = $target.find('.d2h-show'); | ||
var $hideBtn = $target.find('.d2h-hide'); | ||
var $fileList = $target.find('.d2h-file-list'); | ||
@@ -94,3 +91,3 @@ if (hashTag === 'files-summary-show') show(); | ||
// collect all the diff files and execute the highlight on their lines | ||
var $files = $target.find(".d2h-file-wrapper"); | ||
var $files = $target.find('.d2h-file-wrapper'); | ||
$files.map(function(_i, file) { | ||
@@ -100,6 +97,6 @@ var oldLinesState; | ||
var $file = $(file); | ||
var language = $file.data("lang"); | ||
var language = $file.data('lang'); | ||
// collect all the code lines and execute the highlight on them | ||
var $codeLines = $file.find(".d2h-code-line-ctn"); | ||
var $codeLines = $file.find('.d2h-code-line-ctn'); | ||
$codeLines.map(function(_j, line) { | ||
@@ -111,3 +108,3 @@ var $line = $(line); | ||
var lineState; | ||
if (lineParent.className.indexOf("d2h-del") !== -1) { | ||
if (lineParent.className.indexOf('d2h-del') !== -1) { | ||
lineState = oldLinesState; | ||
@@ -120,5 +117,5 @@ } else { | ||
if (lineParent.className.indexOf("d2h-del") !== -1) { | ||
if (lineParent.className.indexOf('d2h-del') !== -1) { | ||
oldLinesState = result.top; | ||
} else if (lineParent.className.indexOf("d2h-ins") !== -1) { | ||
} else if (lineParent.className.indexOf('d2h-ins') !== -1) { | ||
newLinesState = result.top; | ||
@@ -137,3 +134,3 @@ } else { | ||
$line.addClass("hljs"); | ||
$line.addClass('hljs'); | ||
$line.addClass(result.language); | ||
@@ -154,3 +151,3 @@ $line.html(result.value); | ||
console.error("Wrong target provided! Falling back to default value 'body'."); | ||
console.log("Please provide a jQuery object or a valid DOM query string."); | ||
console.log('Please provide a jQuery object or a valid DOM query string.'); | ||
$target = $(defaultTarget); | ||
@@ -207,3 +204,2 @@ } | ||
Diff2HtmlUI.prototype._getSelectedText = function() { | ||
@@ -233,3 +229,2 @@ var sel = window.getSelection(); | ||
global.Diff2HtmlUI = Diff2HtmlUI; | ||
})(); | ||
@@ -247,3 +242,2 @@ | ||
(function() { | ||
function HighlightJS() { | ||
@@ -273,5 +267,5 @@ } | ||
for (var child = node.firstChild; child; child = child.nextSibling) { | ||
if (child.nodeType == 3) | ||
if (child.nodeType === 3) { | ||
offset += child.nodeValue.length; | ||
else if (child.nodeType == 1) { | ||
} else if (child.nodeType === 1) { | ||
result.push({ | ||
@@ -309,3 +303,3 @@ event: 'start', | ||
} | ||
if (original[0].offset != highlighted[0].offset) { | ||
if (original[0].offset !== highlighted[0].offset) { | ||
return (original[0].offset < highlighted[0].offset) ? original : highlighted; | ||
@@ -327,3 +321,3 @@ } | ||
*/ | ||
return highlighted[0].event == 'start' ? original : highlighted; | ||
return highlighted[0].event === 'start' ? original : highlighted; | ||
} | ||
@@ -344,3 +338,3 @@ | ||
function render(event) { | ||
(event.event == 'start' ? open : close)(event.node); | ||
(event.event === 'start' ? open : close)(event.node); | ||
} | ||
@@ -352,4 +346,3 @@ | ||
processed = stream[0].offset; | ||
if (stream == original) { | ||
if (stream === original) { | ||
/* | ||
@@ -365,6 +358,6 @@ On any opening or closing tag of the original markup we first close | ||
stream = selectStream(); | ||
} while (stream == original && stream.length && stream[0].offset == processed); | ||
} while (stream === original && stream.length && stream[0].offset === processed); | ||
nodeStack.reverse().forEach(open); | ||
} else { | ||
if (stream[0].event == 'start') { | ||
if (stream[0].event === 'start') { | ||
nodeStack.push(stream[0].node); | ||
@@ -383,5 +376,4 @@ } else { | ||
module.exports.HighlightJS = new HighlightJS(); | ||
})(); | ||
},{}]},{},[1]); |
@@ -1,1 +0,1 @@ | ||
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module){(function(global){!function(){function Diff2HtmlUI(config){var cfg=config||{};cfg.diff?diffJson=Diff2Html.getJsonFromDiff(cfg.diff):cfg.json&&(diffJson=cfg.json),this._initSelection()}function synchronisedScroll($target,config){config.synchronisedScroll&&$target.find(".d2h-file-side-diff").scroll(function(){var $this=$(this);$this.closest(".d2h-file-wrapper").find(".d2h-file-side-diff").scrollLeft($this.scrollLeft())})}var highlightJS=require("./highlight.js-internals.js").HighlightJS,diffJson=null,defaultTarget="body",currentSelectionColumnId=-1;Diff2HtmlUI.prototype.draw=function(targetId,config){var cfg=config||{},$target=this._getTarget(targetId);$target.html(Diff2Html.getPrettyHtml(diffJson,cfg)),synchronisedScroll($target,config)},Diff2HtmlUI.prototype.fileListCloseable=function(targetId,startVisible){function show(){$showBtn.hide(),$hideBtn.show(),$fileList.show()}function hide(){$hideBtn.hide(),$showBtn.show(),$fileList.hide()}var $target=this._getTarget(targetId),hashTag=this._getHashTag(),$showBtn=$target.find(".d2h-show"),$hideBtn=$target.find(".d2h-hide"),$fileList=$target.find(".d2h-file-list");"files-summary-show"===hashTag?show():"files-summary-hide"===hashTag?hide():startVisible?show():hide(),$showBtn.click(show),$hideBtn.click(hide)},Diff2HtmlUI.prototype.highlightCode=function(targetId){var that=this,$target=that._getTarget(targetId),$files=$target.find(".d2h-file-wrapper");$files.map(function(_i,file){var oldLinesState,newLinesState,$file=$(file),language=$file.data("lang"),$codeLines=$file.find(".d2h-code-line-ctn");$codeLines.map(function(_j,line){var lineState,$line=$(line),text=line.textContent,lineParent=line.parentNode;lineState=-1!==lineParent.className.indexOf("d2h-del")?oldLinesState:newLinesState;var result=hljs.getLanguage(language)?hljs.highlight(language,text,!0,lineState):hljs.highlightAuto(text);-1!==lineParent.className.indexOf("d2h-del")?oldLinesState=result.top:-1!==lineParent.className.indexOf("d2h-ins")?newLinesState=result.top:(oldLinesState=result.top,newLinesState=result.top);var originalStream=highlightJS.nodeStream(line);if(originalStream.length){var resultNode=document.createElementNS("http://www.w3.org/1999/xhtml","div");resultNode.innerHTML=result.value,result.value=highlightJS.mergeStreams(originalStream,highlightJS.nodeStream(resultNode),text)}$line.addClass("hljs"),$line.addClass(result.language),$line.html(result.value)})})},Diff2HtmlUI.prototype._getTarget=function(targetId){var $target;return"object"==typeof targetId&&targetId instanceof jQuery?$target=targetId:"string"==typeof targetId?$target=$(targetId):(console.error("Wrong target provided! Falling back to default value 'body'."),console.log("Please provide a jQuery object or a valid DOM query string."),$target=$(defaultTarget)),$target},Diff2HtmlUI.prototype._getHashTag=function(){var docUrl=document.URL,hashTagIndex=docUrl.indexOf("#"),hashTag=null;return-1!==hashTagIndex&&(hashTag=docUrl.substr(hashTagIndex+1)),hashTag},Diff2HtmlUI.prototype._distinct=function(collection){return collection.filter(function(v,i){return collection.indexOf(v)===i})},Diff2HtmlUI.prototype._initSelection=function(){var body=$("body"),that=this;body.on("mousedown",".d2h-diff-table",function(event){var target=$(event.target),table=target.closest(".d2h-diff-table");target.closest(".d2h-code-line,.d2h-code-side-line").length?(table.removeClass("selecting-left"),table.addClass("selecting-right"),currentSelectionColumnId=1):target.closest(".d2h-code-linenumber,.d2h-code-side-linenumber").length&&(table.removeClass("selecting-right"),table.addClass("selecting-left"),currentSelectionColumnId=0)}),body.on("copy",".d2h-diff-table",function(event){var clipboardData=event.originalEvent.clipboardData,text=that._getSelectedText();clipboardData.setData("text",text),event.preventDefault()})},Diff2HtmlUI.prototype._getSelectedText=function(){var sel=window.getSelection(),range=sel.getRangeAt(0),doc=range.cloneContents(),nodes=doc.querySelectorAll("tr"),text="",idx=currentSelectionColumnId;return 0===nodes.length?text=doc.textContent:[].forEach.call(nodes,function(tr,i){var td=tr.cells[1===tr.cells.length?0:idx];text+=(i?"\n":"")+td.textContent.replace(/(?:\r\n|\r|\n)/g,"")}),text},module.exports.Diff2HtmlUI=Diff2HtmlUI,global.Diff2HtmlUI=Diff2HtmlUI}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./highlight.js-internals.js":2}],2:[function(require,module){!function(){function HighlightJS(){}function escape(value){return value.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function tag(node){return node.nodeName.toLowerCase()}HighlightJS.prototype.nodeStream=function(node){var result=[];return function _nodeStream(node,offset){for(var child=node.firstChild;child;child=child.nextSibling)3==child.nodeType?offset+=child.nodeValue.length:1==child.nodeType&&(result.push({event:"start",offset:offset,node:child}),offset=_nodeStream(child,offset),tag(child).match(/br|hr|img|input/)||result.push({event:"stop",offset:offset,node:child}));return offset}(node,0),result},HighlightJS.prototype.mergeStreams=function(original,highlighted,value){function selectStream(){return original.length&&highlighted.length?original[0].offset!=highlighted[0].offset?original[0].offset<highlighted[0].offset?original:highlighted:"start"==highlighted[0].event?original:highlighted:original.length?original:highlighted}function open(node){function attrStr(a){return" "+a.nodeName+'="'+escape(a.value)+'"'}result+="<"+tag(node)+Array.prototype.map.call(node.attributes,attrStr).join("")+">"}function close(node){result+="</"+tag(node)+">"}function render(event){("start"==event.event?open:close)(event.node)}for(var processed=0,result="",nodeStack=[];original.length||highlighted.length;){var stream=selectStream();if(result+=escape(value.substr(processed,stream[0].offset-processed)),processed=stream[0].offset,stream==original){nodeStack.reverse().forEach(close);do render(stream.splice(0,1)[0]),stream=selectStream();while(stream==original&&stream.length&&stream[0].offset==processed);nodeStack.reverse().forEach(open)}else"start"==stream[0].event?nodeStack.push(stream[0].node):nodeStack.pop(),render(stream.splice(0,1)[0])}return result+escape(value.substr(processed))},module.exports.HighlightJS=new HighlightJS}()},{}]},{},[1]); | ||
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module){(function(global){!function(){function Diff2HtmlUI(config){var cfg=config||{};cfg.diff?diffJson=Diff2Html.getJsonFromDiff(cfg.diff):cfg.json&&(diffJson=cfg.json),this._initSelection()}function synchronisedScroll($target,config){config.synchronisedScroll&&$target.find(".d2h-file-side-diff").scroll(function(){var $this=$(this);$this.closest(".d2h-file-wrapper").find(".d2h-file-side-diff").scrollLeft($this.scrollLeft())})}var highlightJS=require("./highlight.js-internals.js").HighlightJS,diffJson=null,defaultTarget="body",currentSelectionColumnId=-1;Diff2HtmlUI.prototype.draw=function(targetId,config){var cfg=config||{},$target=this._getTarget(targetId);$target.html(Diff2Html.getPrettyHtml(diffJson,cfg)),synchronisedScroll($target,config)},Diff2HtmlUI.prototype.fileListCloseable=function(targetId,startVisible){function show(){$showBtn.hide(),$hideBtn.show(),$fileList.show()}function hide(){$hideBtn.hide(),$showBtn.show(),$fileList.hide()}var $target=this._getTarget(targetId),hashTag=this._getHashTag(),$showBtn=$target.find(".d2h-show"),$hideBtn=$target.find(".d2h-hide"),$fileList=$target.find(".d2h-file-list");"files-summary-show"===hashTag?show():"files-summary-hide"===hashTag?hide():startVisible?show():hide(),$showBtn.click(show),$hideBtn.click(hide)},Diff2HtmlUI.prototype.highlightCode=function(targetId){var that=this,$target=that._getTarget(targetId),$files=$target.find(".d2h-file-wrapper");$files.map(function(_i,file){var oldLinesState,newLinesState,$file=$(file),language=$file.data("lang"),$codeLines=$file.find(".d2h-code-line-ctn");$codeLines.map(function(_j,line){var lineState,$line=$(line),text=line.textContent,lineParent=line.parentNode;lineState=-1!==lineParent.className.indexOf("d2h-del")?oldLinesState:newLinesState;var result=hljs.getLanguage(language)?hljs.highlight(language,text,!0,lineState):hljs.highlightAuto(text);-1!==lineParent.className.indexOf("d2h-del")?oldLinesState=result.top:-1!==lineParent.className.indexOf("d2h-ins")?newLinesState=result.top:(oldLinesState=result.top,newLinesState=result.top);var originalStream=highlightJS.nodeStream(line);if(originalStream.length){var resultNode=document.createElementNS("http://www.w3.org/1999/xhtml","div");resultNode.innerHTML=result.value,result.value=highlightJS.mergeStreams(originalStream,highlightJS.nodeStream(resultNode),text)}$line.addClass("hljs"),$line.addClass(result.language),$line.html(result.value)})})},Diff2HtmlUI.prototype._getTarget=function(targetId){var $target;return"object"==typeof targetId&&targetId instanceof jQuery?$target=targetId:"string"==typeof targetId?$target=$(targetId):(console.error("Wrong target provided! Falling back to default value 'body'."),console.log("Please provide a jQuery object or a valid DOM query string."),$target=$(defaultTarget)),$target},Diff2HtmlUI.prototype._getHashTag=function(){var docUrl=document.URL,hashTagIndex=docUrl.indexOf("#"),hashTag=null;return-1!==hashTagIndex&&(hashTag=docUrl.substr(hashTagIndex+1)),hashTag},Diff2HtmlUI.prototype._distinct=function(collection){return collection.filter(function(v,i){return collection.indexOf(v)===i})},Diff2HtmlUI.prototype._initSelection=function(){var body=$("body"),that=this;body.on("mousedown",".d2h-diff-table",function(event){var target=$(event.target),table=target.closest(".d2h-diff-table");target.closest(".d2h-code-line,.d2h-code-side-line").length?(table.removeClass("selecting-left"),table.addClass("selecting-right"),currentSelectionColumnId=1):target.closest(".d2h-code-linenumber,.d2h-code-side-linenumber").length&&(table.removeClass("selecting-right"),table.addClass("selecting-left"),currentSelectionColumnId=0)}),body.on("copy",".d2h-diff-table",function(event){var clipboardData=event.originalEvent.clipboardData,text=that._getSelectedText();clipboardData.setData("text",text),event.preventDefault()})},Diff2HtmlUI.prototype._getSelectedText=function(){var sel=window.getSelection(),range=sel.getRangeAt(0),doc=range.cloneContents(),nodes=doc.querySelectorAll("tr"),text="",idx=currentSelectionColumnId;return 0===nodes.length?text=doc.textContent:[].forEach.call(nodes,function(tr,i){var td=tr.cells[1===tr.cells.length?0:idx];text+=(i?"\n":"")+td.textContent.replace(/(?:\r\n|\r|\n)/g,"")}),text},module.exports.Diff2HtmlUI=Diff2HtmlUI,global.Diff2HtmlUI=Diff2HtmlUI}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./highlight.js-internals.js":2}],2:[function(require,module){!function(){function HighlightJS(){}function escape(value){return value.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function tag(node){return node.nodeName.toLowerCase()}HighlightJS.prototype.nodeStream=function(node){var result=[];return function _nodeStream(node,offset){for(var child=node.firstChild;child;child=child.nextSibling)3===child.nodeType?offset+=child.nodeValue.length:1===child.nodeType&&(result.push({event:"start",offset:offset,node:child}),offset=_nodeStream(child,offset),tag(child).match(/br|hr|img|input/)||result.push({event:"stop",offset:offset,node:child}));return offset}(node,0),result},HighlightJS.prototype.mergeStreams=function(original,highlighted,value){function selectStream(){return original.length&&highlighted.length?original[0].offset!==highlighted[0].offset?original[0].offset<highlighted[0].offset?original:highlighted:"start"===highlighted[0].event?original:highlighted:original.length?original:highlighted}function open(node){function attrStr(a){return" "+a.nodeName+'="'+escape(a.value)+'"'}result+="<"+tag(node)+Array.prototype.map.call(node.attributes,attrStr).join("")+">"}function close(node){result+="</"+tag(node)+">"}function render(event){("start"===event.event?open:close)(event.node)}for(var processed=0,result="",nodeStack=[];original.length||highlighted.length;){var stream=selectStream();if(result+=escape(value.substr(processed,stream[0].offset-processed)),processed=stream[0].offset,stream===original){nodeStack.reverse().forEach(close);do render(stream.splice(0,1)[0]),stream=selectStream();while(stream===original&&stream.length&&stream[0].offset===processed);nodeStack.reverse().forEach(open)}else"start"===stream[0].event?nodeStack.push(stream[0].node):nodeStack.pop(),render(stream.splice(0,1)[0])}return result+escape(value.substr(processed))},module.exports.HighlightJS=new HighlightJS}()},{}]},{},[1]); |
{ | ||
"name": "diff2html", | ||
"version": "2.0.0-rc.8", | ||
"version": "2.0.0-rc.9", | ||
"homepage": "http://rtfpessoa.github.io/diff2html/", | ||
@@ -42,3 +42,3 @@ "description": "Fast Diff to colorized HTML", | ||
"templates": "./scripts/hulk.js --wrapper node --variable 'browserTemplates' ./src/templates/*.mustache > ./src/templates/diff2html-templates.js", | ||
"style": "jscs src/*.js src/ui/js/*.js", | ||
"style": "eslint src/*.js src/ui/js/*.js", | ||
"coverage": "istanbul cover _mocha -- -u exports -R spec ./test/**/*", | ||
@@ -57,3 +57,3 @@ "check-coverage": "istanbul check-coverage --statements 90 --functions 90 --branches 85 --lines 90 ./coverage/coverage.json", | ||
"dependencies": { | ||
"diff": "^2.2.2", | ||
"diff": "^2.2.3", | ||
"hogan.js": "^3.0.2" | ||
@@ -63,10 +63,12 @@ }, | ||
"autoprefixer": "^6.3.6", | ||
"browserify": "^13.0.0", | ||
"clean-css": "^3.4.10", | ||
"browserify": "^13.0.1", | ||
"clean-css": "^3.4.18", | ||
"codacy-coverage": "^1.1.3", | ||
"eslint": "^3.0.1", | ||
"eslint-plugin-promise": "^1.3.2", | ||
"eslint-plugin-standard": "^1.3.2", | ||
"fast-html-parser": "^1.0.1", | ||
"istanbul": "^0.4.2", | ||
"jscs": "^3.0.3", | ||
"istanbul": "^0.4.4", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^2.4.5", | ||
"mocha": "^2.5.3", | ||
"nopt": "^3.0.6", | ||
@@ -73,0 +75,0 @@ "postcss-cli": "^2.5.2", |
# diff2html | ||
[![Circle CI](https://circleci.com/gh/rtfpessoa/diff2html.svg?style=svg)](https://circleci.com/gh/rtfpessoa/diff2html) | ||
[![Codacy Code Badge](https://api.codacy.com/project/badge/grade/06412dc3f5a14f568778d0db8a1f7dc8)](https://www.codacy.com/app/Codacy/diff2html) | ||
[![Codacy Coverage Badge](https://api.codacy.com/project/badge/coverage/06412dc3f5a14f568778d0db8a1f7dc8)](https://www.codacy.com/app/Codacy/diff2html) | ||
[![Circle CI](https://circleci.com/gh/rtfpessoa/diff2html.svg?style=svg)](https://circleci.com/gh/rtfpessoa/diff2html) | ||
[![Dependency Status](https://dependencyci.com/github/rtfpessoa/diff2html/badge)](https://dependencyci.com/github/rtfpessoa/diff2html) | ||
@@ -7,0 +8,0 @@ [![npm](https://img.shields.io/npm/v/diff2html.svg)](https://www.npmjs.com/package/diff2html) |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
var utils = require('./utils.js').Utils; | ||
@@ -86,7 +85,7 @@ | ||
if (values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line)) { | ||
if ((values = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(line))) { | ||
currentFile.isCombined = false; | ||
oldLine = values[1]; | ||
newLine = values[2]; | ||
} else if (values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line)) { | ||
} else if ((values = /^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(line))) { | ||
currentFile.isCombined = true; | ||
@@ -97,3 +96,3 @@ oldLine = values[1]; | ||
} else { | ||
console.error("Failed to parse lines, starting in 0!"); | ||
console.error('Failed to parse lines, starting in 0!'); | ||
oldLine = 0; | ||
@@ -129,3 +128,2 @@ newLine = 0; | ||
currentBlock.lines.push(currentLine); | ||
} else if (utils.startsWith(line, delLinePrefixes)) { | ||
@@ -139,3 +137,2 @@ currentFile.deletedLines++; | ||
currentBlock.lines.push(currentLine); | ||
} else { | ||
@@ -222,8 +219,7 @@ currentLine.type = LINE_TYPE.CONTEXT; | ||
(utils.startsWith(line, oldFileNameHeader) && | ||
utils.startsWith(nxtLine, newFileNameHeader) && utils.startsWith(afterNxtLine, hunkHeaderPrefix)) || | ||
utils.startsWith(nxtLine, newFileNameHeader)) || | ||
(utils.startsWith(line, newFileNameHeader) && | ||
utils.startsWith(prevLine, oldFileNameHeader) && utils.startsWith(nxtLine, hunkHeaderPrefix)) | ||
utils.startsWith(prevLine, oldFileNameHeader)) | ||
) { | ||
/* | ||
@@ -250,6 +246,8 @@ * --- Date Timestamp[FractionalSeconds] TimeZone | ||
} | ||
} | ||
if (currentFile && utils.startsWith(line, hunkHeaderPrefix)) { | ||
if ( | ||
(currentFile && utils.startsWith(line, hunkHeaderPrefix)) || | ||
(currentFile.isGitDiff && currentFile && currentFile.oldName && currentFile.newName && !currentBlock) | ||
) { | ||
startBlock(line); | ||
@@ -335,3 +333,3 @@ return; | ||
function getSrcFilename(line, cfg) { | ||
var prefixes = ["a/", "i/", "w/", "c/", "o/"]; | ||
var prefixes = ['a/', 'i/', 'w/', 'c/', 'o/']; | ||
@@ -346,3 +344,3 @@ if (cfg.srcPrefix) { | ||
function getDstFilename(line, cfg) { | ||
var prefixes = ["b/", "i/", "w/", "c/", "o/"]; | ||
var prefixes = ['b/', 'i/', 'w/', 'c/', 'o/']; | ||
@@ -377,3 +375,2 @@ if (cfg.dstPrefix) { | ||
module.exports.DiffParser = new DiffParser(); | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
var diffParser = require('./diff-parser.js').DiffParser; | ||
@@ -61,3 +60,2 @@ var fileLister = require('./file-list-printer.js').FileListPrinter; | ||
/* | ||
@@ -112,3 +110,2 @@ * Deprecated methods - The following methods exist only to maintain compatibility with previous versions | ||
global.Diff2Html = diffObject; | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
var printerUtils = require('./printer-utils.js').PrinterUtils; | ||
@@ -44,3 +43,2 @@ | ||
module.exports.FileListPrinter = new FileListPrinter(); | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
var fs = require('fs'); | ||
@@ -79,3 +78,2 @@ var path = require('path'); | ||
module.exports.HoganJsUtils = new HoganJsUtils(); | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
var LineByLinePrinter = require('./line-by-line-printer.js').LineByLinePrinter; | ||
@@ -28,3 +27,2 @@ var SideBySidePrinter = require('./side-by-side-printer.js').SideBySidePrinter; | ||
module.exports.HtmlPrinter = new HtmlPrinter(); | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
var diffParser = require('./diff-parser.js').DiffParser; | ||
@@ -83,3 +82,2 @@ var printerUtils = require('./printer-utils.js').PrinterUtils; | ||
return file.blocks.map(function(block) { | ||
var lines = that.makeColumnLineNumberHtml(block); | ||
@@ -214,3 +212,2 @@ var oldLines = []; | ||
module.exports.LineByLinePrinter = LineByLinePrinter; | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
var jsDiff = require('diff'); | ||
@@ -89,3 +88,2 @@ var utils = require('./utils.js').Utils; | ||
return oldFilename + ' → ' + newFilename; | ||
} else if (newFilename && !isDevNullName(newFilename)) { | ||
@@ -222,3 +220,2 @@ return newFilename; | ||
module.exports.PrinterUtils = new PrinterUtils(); | ||
})(); |
@@ -10,3 +10,2 @@ /* | ||
(function() { | ||
var Rematch = {}; | ||
@@ -27,6 +26,6 @@ | ||
function levenshtein(a, b) { | ||
if (a.length == 0) { | ||
if (a.length === 0) { | ||
return b.length; | ||
} | ||
if (b.length == 0) { | ||
if (b.length === 0) { | ||
return a.length; | ||
@@ -52,3 +51,3 @@ } | ||
for (j = 1; j <= a.length; j++) { | ||
if (b.charAt(i - 1) == a.charAt(j - 1)) { | ||
if (b.charAt(i - 1) === a.charAt(j - 1)) { | ||
matrix[i][j] = matrix[i - 1][j - 1]; | ||
@@ -79,8 +78,2 @@ } else { | ||
function findBestMatch(a, b, cache) { | ||
var cachecount = 0; | ||
for (var key in cache) { | ||
cachecount++; | ||
} | ||
var bestMatchDist = Infinity; | ||
@@ -109,3 +102,3 @@ var bestMatch; | ||
function group(a, b, level, cache) { | ||
if (typeof (cache) === "undefined") { | ||
if (typeof (cache) === 'undefined') { | ||
cache = {}; | ||
@@ -153,3 +146,2 @@ } | ||
module.exports.Rematch = Rematch; | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
var diffParser = require('./diff-parser.js').DiffParser; | ||
@@ -85,3 +84,2 @@ var printerUtils = require('./printer-utils.js').PrinterUtils; | ||
file.blocks.forEach(function(block) { | ||
fileHtml.left += that.makeSideHtml(block.header); | ||
@@ -249,3 +247,2 @@ fileHtml.right += that.makeSideHtml(''); | ||
module.exports.SideBySidePrinter = SideBySidePrinter; | ||
})(); |
@@ -14,7 +14,6 @@ /* | ||
(function() { | ||
var highlightJS = require('./highlight.js-internals.js').HighlightJS; | ||
var diffJson = null; | ||
var defaultTarget = "body"; | ||
var defaultTarget = 'body'; | ||
var currentSelectionColumnId = -1; | ||
@@ -44,9 +43,7 @@ | ||
if (config.synchronisedScroll) { | ||
$target.find(".d2h-file-side-diff").scroll(function() { | ||
$target.find('.d2h-file-side-diff').scroll(function() { | ||
var $this = $(this); | ||
$this.closest(".d2h-file-wrapper").find(".d2h-file-side-diff") | ||
$this.closest('.d2h-file-wrapper').find('.d2h-file-side-diff') | ||
.scrollLeft($this.scrollLeft()); | ||
}); | ||
} | ||
@@ -60,5 +57,5 @@ } | ||
var $showBtn = $target.find(".d2h-show"); | ||
var $hideBtn = $target.find(".d2h-hide"); | ||
var $fileList = $target.find(".d2h-file-list"); | ||
var $showBtn = $target.find('.d2h-show'); | ||
var $hideBtn = $target.find('.d2h-hide'); | ||
var $fileList = $target.find('.d2h-file-list'); | ||
@@ -92,3 +89,3 @@ if (hashTag === 'files-summary-show') show(); | ||
// collect all the diff files and execute the highlight on their lines | ||
var $files = $target.find(".d2h-file-wrapper"); | ||
var $files = $target.find('.d2h-file-wrapper'); | ||
$files.map(function(_i, file) { | ||
@@ -98,6 +95,6 @@ var oldLinesState; | ||
var $file = $(file); | ||
var language = $file.data("lang"); | ||
var language = $file.data('lang'); | ||
// collect all the code lines and execute the highlight on them | ||
var $codeLines = $file.find(".d2h-code-line-ctn"); | ||
var $codeLines = $file.find('.d2h-code-line-ctn'); | ||
$codeLines.map(function(_j, line) { | ||
@@ -109,3 +106,3 @@ var $line = $(line); | ||
var lineState; | ||
if (lineParent.className.indexOf("d2h-del") !== -1) { | ||
if (lineParent.className.indexOf('d2h-del') !== -1) { | ||
lineState = oldLinesState; | ||
@@ -118,5 +115,5 @@ } else { | ||
if (lineParent.className.indexOf("d2h-del") !== -1) { | ||
if (lineParent.className.indexOf('d2h-del') !== -1) { | ||
oldLinesState = result.top; | ||
} else if (lineParent.className.indexOf("d2h-ins") !== -1) { | ||
} else if (lineParent.className.indexOf('d2h-ins') !== -1) { | ||
newLinesState = result.top; | ||
@@ -135,3 +132,3 @@ } else { | ||
$line.addClass("hljs"); | ||
$line.addClass('hljs'); | ||
$line.addClass(result.language); | ||
@@ -152,3 +149,3 @@ $line.html(result.value); | ||
console.error("Wrong target provided! Falling back to default value 'body'."); | ||
console.log("Please provide a jQuery object or a valid DOM query string."); | ||
console.log('Please provide a jQuery object or a valid DOM query string.'); | ||
$target = $(defaultTarget); | ||
@@ -205,3 +202,2 @@ } | ||
Diff2HtmlUI.prototype._getSelectedText = function() { | ||
@@ -231,3 +227,2 @@ var sel = window.getSelection(); | ||
global.Diff2HtmlUI = Diff2HtmlUI; | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
function HighlightJS() { | ||
@@ -35,5 +34,5 @@ } | ||
for (var child = node.firstChild; child; child = child.nextSibling) { | ||
if (child.nodeType == 3) | ||
if (child.nodeType === 3) { | ||
offset += child.nodeValue.length; | ||
else if (child.nodeType == 1) { | ||
} else if (child.nodeType === 1) { | ||
result.push({ | ||
@@ -71,3 +70,3 @@ event: 'start', | ||
} | ||
if (original[0].offset != highlighted[0].offset) { | ||
if (original[0].offset !== highlighted[0].offset) { | ||
return (original[0].offset < highlighted[0].offset) ? original : highlighted; | ||
@@ -89,3 +88,3 @@ } | ||
*/ | ||
return highlighted[0].event == 'start' ? original : highlighted; | ||
return highlighted[0].event === 'start' ? original : highlighted; | ||
} | ||
@@ -106,3 +105,3 @@ | ||
function render(event) { | ||
(event.event == 'start' ? open : close)(event.node); | ||
(event.event === 'start' ? open : close)(event.node); | ||
} | ||
@@ -114,4 +113,3 @@ | ||
processed = stream[0].offset; | ||
if (stream == original) { | ||
if (stream === original) { | ||
/* | ||
@@ -127,6 +125,6 @@ On any opening or closing tag of the original markup we first close | ||
stream = selectStream(); | ||
} while (stream == original && stream.length && stream[0].offset == processed); | ||
} while (stream === original && stream.length && stream[0].offset === processed); | ||
nodeStack.reverse().forEach(open); | ||
} else { | ||
if (stream[0].event == 'start') { | ||
if (stream[0].event === 'start') { | ||
nodeStack.push(stream[0].node); | ||
@@ -145,3 +143,2 @@ } else { | ||
module.exports.HighlightJS = new HighlightJS(); | ||
})(); |
@@ -9,3 +9,2 @@ /* | ||
(function() { | ||
function Utils() { | ||
@@ -42,7 +41,6 @@ } | ||
Utils.prototype.valueOrEmpty = function(value) { | ||
return value ? value : ''; | ||
return value || ''; | ||
}; | ||
module.exports.Utils = new Utils(); | ||
})(); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
329399
183
14
5959
Updateddiff@^2.2.3