diff --git a/diff2html.css b/diff2html.css
index f35e3df..6e80d69 100644
--- a/diff2html.css
+++ b/diff2html.css
@@ -3,7 +3,7 @@
* Diff to HTML (diff2html.css)
* Author: rtfpessoa
* Date: Friday 29 August 2014
- * Last Update: Saturday 27 September 2014
+ * Last Update: Sunday 25 January 2015
*
*/
@@ -86,22 +86,32 @@
margin-right: -4px;
}
-.d2h-code-line {
+.d2h-code-line.hljs {
+ display: block;
white-space: pre;
- padding-left: 10px;
- padding-right: 10px;
+ padding: 0 10px;
height: 18px;
line-height: 18px;
margin-left: 80px;
+ /* Override HighlightJS */
+ color: inherit;
+ overflow-x: inherit;
+ background: none;
+ /* ******************** */
}
.d2h-code-side-line {
+ display: block;
white-space: pre;
- padding-left: 10px;
- padding-right: 10px;
+ padding: 0 10px;
height: 18px;
line-height: 18px;
margin-left: 50px;
+ /* Override HighlightJS */
+ color: inherit;
+ overflow-x: inherit;
+ background: none;
+ /* ******************** */
}
.d2h-code-line del,
diff --git a/diff2html.js b/diff2html.js
index d0268d4..d9b342b 100644
--- a/diff2html.js
+++ b/diff2html.js
@@ -3,7 +3,7 @@
* Diff to HTML (diff2html.js)
* Author: rtfpessoa
* Date: Friday 29 August 2014
- * Last Update: Saturday 24 January 2015
+ * Last Update: Sunday 25 January 2015
*
* Diff command:
* git diff
@@ -211,7 +211,7 @@
return file.blocks.map(function (block) {
var lines = "
\n" +
- " | \n" +
+ " | \n" +
" " +
" " + escape(block.header) + " " +
" | \n" +
@@ -312,14 +312,14 @@
fileHtml.left += "
\n" +
" | \n" +
- " " +
+ " | " +
" " + escape(block.header) + " " +
" | \n" +
"
\n";
fileHtml.right += "\n" +
" | \n" +
- " " +
+ " | " +
" " +
" | \n" +
"
\n";
diff --git a/diff2html.min.css b/diff2html.min.css
index b13efa6..7b3a771 100644
--- a/diff2html.min.css
+++ b/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{background-color:#ceffce;border:1px solid #b4e2b4;color:#399839;border-radius:5px 0 0 5px;padding:2px;width:25px}.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}.d2h-file-side-diff{display:inline-block;overflow-x:scroll;width:50%;margin-right:-4px}.d2h-code-line{white-space:pre;padding-left:10px;padding-right:10px;height:18px;line-height:18px;margin-left:80px}.d2h-code-side-line{white-space:pre;padding-left:10px;padding-right:10px;height:18px;line-height:18px;margin-left:50px}.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}.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 #eee;border-width: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 #eee;border-width: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}
\ 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{background-color:#ceffce;border:1px solid #b4e2b4;color:#399839;border-radius:5px 0 0 5px;padding:2px;width:25px}.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}.d2h-file-side-diff{display:inline-block;overflow-x:scroll;width:50%;margin-right:-4px}.d2h-code-line.hljs{display:block;white-space:pre;padding:0 10px;height:18px;line-height:18px;margin-left:80px;color:inherit;overflow-x:inherit;background:0 0}.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:0 0}.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}.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,.3);text-align:right;border:solid #eee;border-width: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,.3);text-align:right;border:solid #eee;border-width: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,.3);border-color:#d5e4f2}
\ No newline at end of file
diff --git a/diff2html.min.js b/diff2html.min.js
index 9071c99..a54636b 100644
--- a/diff2html.min.js
+++ b/diff2html.min.js
@@ -1 +1 @@
-!function(window){var ClassVariable;return ClassVariable=function(){function Diff2Html(){}function escape(str){return str.slice(0).replace(/&/g,"&").replace(//g,">").replace(/\t/g," ")}function startsWith(str,start){return 0===str.indexOf(start)}function valueOrEmpty(value){return value?value:""}function diffHighlight(diffLine1,diffLine2){var highlightedLine=diffString(diffLine1.substr(1),diffLine2.substr(1));return{o:diffLine1.charAt(0)+removeIns(highlightedLine),n:diffLine2.charAt(0)+removeDel(highlightedLine)}}var LINE_TYPE={INSERTS:"d2h-ins",DELETES:"d2h-del",CONTEXT:"d2h-cntx",INFO:"d2h-info"};Diff2Html.prototype.getPrettyHtmlFromDiff=function(diffInput){var diffJson=generateDiffJson(diffInput);return generateJsonHtml(diffJson)},Diff2Html.prototype.getJsonFromDiff=function(diffInput){return generateDiffJson(diffInput)},Diff2Html.prototype.getPrettyHtmlFromJson=function(diffJson){return generateJsonHtml(diffJson)},Diff2Html.prototype.getPrettySideBySideHtmlFromDiff=function(diffInput){var diffJson=generateDiffJson(diffInput);return generateSideBySideJsonHtml(diffJson)},Diff2Html.prototype.getPrettySideBySideHtmlFromJson=function(diffJson){return generateSideBySideJsonHtml(diffJson)};var instance,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=/^@@ -(\d+),\d+ \+(\d+),\d+ @@.*/.exec(line)||/^@@@ -(\d+),\d+ -\d+,\d+ \+(\d+),\d+ @@@.*/.exec(line)||[0,0,0];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,startsWith(line,"+")||startsWith(line," +")?(currentFile.addedLines++,currentLine.type=LINE_TYPE.INSERTS,currentLine.oldNumber=null,currentLine.newNumber=newLine++,currentBlock.lines.push(currentLine)):startsWith(line,"-")||startsWith(line," -")?(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");return diffLines.forEach(function(line){if(line&&!startsWith(line,"*")&&!startsWith(line,"new")&&!startsWith(line,"index")){var values=[];startsWith(line,"diff")?startFile():currentFile&&!currentFile.oldName&&(values=/^--- a\/(\S+).*$/.exec(line))?currentFile.oldName=values[1]:currentFile&&!currentFile.newName&&(values=/^\+\+\+ b\/(\S+).*$/.exec(line))?currentFile.newName=values[1]:currentFile&&startsWith(line,"@@")?startBlock(line):currentBlock&&createLine(line)}}),saveBlock(),saveFile(),files},generateJsonHtml=function(diffFiles){return'\n'+diffFiles.map(function(file){return'
\n \n
\n
\n
\n \n '+generateFileHtml(file)+" \n
\n
\n
\n
\n"}).join("\n")+"
\n"},generateFileHtml=function(file){return file.blocks.map(function(block){for(var lines='\n | \n '+escape(block.header)+" | \n
\n",i=0;i\n '+valueOrEmpty(oldNumber)+' '+valueOrEmpty(newNumber)+' | \n '+content+" | \n\n"},generateSideBySideJsonHtml=function(diffFiles){return'\n'+diffFiles.map(function(file){var diffs=generateSideBySideFileHtml(file);return'
\n"}).join("\n")+"
\n"},generateSideBySideFileHtml=function(file){var fileHtml={};return fileHtml.left="",fileHtml.right="",file.blocks.forEach(function(block){fileHtml.left+='\n | \n '+escape(block.header)+" | \n
\n",fileHtml.right+='\n | \n | \n
\n';for(var i=0;i\n '+number+' | \n '+content+" | \n \n"},getDiffName=function(oldFilename,newFilename){return oldFilename&&newFilename&&oldFilename!==newFilename?oldFilename+" -> "+newFilename:newFilename?newFilename:oldFilename?oldFilename:"Unknown filename"},removeIns=function(line){return line.replace(/(((.|\n)*?)<\/ins>)/g,"")},removeDel=function(line){return line.replace(/(((.|\n)*?)<\/del>)/g,"")};return{getInstance:function(){return void 0===instance&&(instance=new Diff2Html,instance.constructor=null),instance}}}(),window.Diff2Html=ClassVariable.getInstance(),window.Diff2Html}(window);
\ No newline at end of file
+!function(window){var ClassVariable;return ClassVariable=function(){function Diff2Html(){}function escape(str){return str.slice(0).replace(/&/g,"&").replace(//g,">").replace(/\t/g," ")}function startsWith(str,start){return 0===str.indexOf(start)}function valueOrEmpty(value){return value?value:""}function diffHighlight(diffLine1,diffLine2){var highlightedLine=diffString(diffLine1.substr(1),diffLine2.substr(1));return{o:diffLine1.charAt(0)+removeIns(highlightedLine),n:diffLine2.charAt(0)+removeDel(highlightedLine)}}var LINE_TYPE={INSERTS:"d2h-ins",DELETES:"d2h-del",CONTEXT:"d2h-cntx",INFO:"d2h-info"};Diff2Html.prototype.getPrettyHtmlFromDiff=function(diffInput){var diffJson=generateDiffJson(diffInput);return generateJsonHtml(diffJson)},Diff2Html.prototype.getJsonFromDiff=function(diffInput){return generateDiffJson(diffInput)},Diff2Html.prototype.getPrettyHtmlFromJson=function(diffJson){return generateJsonHtml(diffJson)},Diff2Html.prototype.getPrettySideBySideHtmlFromDiff=function(diffInput){var diffJson=generateDiffJson(diffInput);return generateSideBySideJsonHtml(diffJson)},Diff2Html.prototype.getPrettySideBySideHtmlFromJson=function(diffJson){return generateSideBySideJsonHtml(diffJson)};var instance,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=/^@@ -(\d+),\d+ \+(\d+),\d+ @@.*/.exec(line)||/^@@@ -(\d+),\d+ -\d+,\d+ \+(\d+),\d+ @@@.*/.exec(line)||[0,0,0];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,startsWith(line,"+")||startsWith(line," +")?(currentFile.addedLines++,currentLine.type=LINE_TYPE.INSERTS,currentLine.oldNumber=null,currentLine.newNumber=newLine++,currentBlock.lines.push(currentLine)):startsWith(line,"-")||startsWith(line," -")?(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");return diffLines.forEach(function(line){if(line&&!startsWith(line,"*")&&!startsWith(line,"new")&&!startsWith(line,"index")){var values=[];startsWith(line,"diff")?startFile():currentFile&&!currentFile.oldName&&(values=/^--- a\/(\S+).*$/.exec(line))?currentFile.oldName=values[1]:currentFile&&!currentFile.newName&&(values=/^\+\+\+ b\/(\S+).*$/.exec(line))?currentFile.newName=values[1]:currentFile&&startsWith(line,"@@")?startBlock(line):currentBlock&&createLine(line)}}),saveBlock(),saveFile(),files},generateJsonHtml=function(diffFiles){return'\n'+diffFiles.map(function(file){return'
\n \n
\n
\n
\n \n '+generateFileHtml(file)+" \n
\n
\n
\n
\n"}).join("\n")+"
\n"},generateFileHtml=function(file){return file.blocks.map(function(block){for(var lines='\n | \n '+escape(block.header)+" | \n
\n",i=0;i\n '+valueOrEmpty(oldNumber)+' '+valueOrEmpty(newNumber)+' | \n '+content+" | \n\n"},generateSideBySideJsonHtml=function(diffFiles){return'\n'+diffFiles.map(function(file){var diffs=generateSideBySideFileHtml(file);return'
\n"}).join("\n")+"
\n"},generateSideBySideFileHtml=function(file){var fileHtml={};return fileHtml.left="",fileHtml.right="",file.blocks.forEach(function(block){fileHtml.left+='\n | \n '+escape(block.header)+" | \n
\n",fileHtml.right+='\n | \n | \n
\n';for(var i=0;i\n '+number+' | \n '+content+" | \n \n"},getDiffName=function(oldFilename,newFilename){return oldFilename&&newFilename&&oldFilename!==newFilename?oldFilename+" -> "+newFilename:newFilename?newFilename:oldFilename?oldFilename:"Unknown filename"},removeIns=function(line){return line.replace(/(((.|\n)*?)<\/ins>)/g,"")},removeDel=function(line){return line.replace(/(((.|\n)*?)<\/del>)/g,"")};return{getInstance:function(){return void 0===instance&&(instance=new Diff2Html,instance.constructor=null),instance}}}(),window.Diff2Html=ClassVariable.getInstance(),window.Diff2Html}(window);
\ No newline at end of file
diff --git a/index.html b/index.html
index 5b88e58..bffbf42 100644
--- a/index.html
+++ b/index.html
@@ -8,13 +8,19 @@
Diff to HTML (template.html)
Author: rtfpessoa
Date: Friday 29 August 2014
- Last Update: Saturday 27 September 2014
+ Last Update: Sunday 25 January 2015
-->
+
+
+
+
+
+
diff --git a/jsdiff.js b/jsdiff.js
index bc05fc3..70792d4 100644
--- a/jsdiff.js
+++ b/jsdiff.js
@@ -10,7 +10,6 @@
* http://ejohn.org/projects/javascript-diff-algorithm/
*/
-
function diffString(o, n) {
o = o.replace(/\s+$/, '');
n = n.replace(/\s+$/, '');