Merge pull request #73 from rtfpessoa/support-unified-diffs
Add support for parsing unified diffs
This commit is contained in:
commit
2b05eaf0fa
4 changed files with 345 additions and 266 deletions
|
|
@ -1,252 +1,258 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Diff to HTML by rtfpessoa</title>
|
<title>Diff to HTML by rtfpessoa</title>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Diff to HTML (index.html)
|
Diff to HTML (index.html)
|
||||||
Author: rtfpessoa
|
Author: rtfpessoa
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/github.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/styles/github.min.css">
|
||||||
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
|
||||||
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/highlight.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/languages/scala.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.3.0/languages/scala.min.js"></script>
|
||||||
|
|
||||||
<!-- diff2html -->
|
<!-- diff2html -->
|
||||||
<link rel="stylesheet" type="text/css" href="../dist/diff2html.css">
|
<link rel="stylesheet" type="text/css" href="../dist/diff2html.css">
|
||||||
<script type="text/javascript" src="../dist/diff2html.js"></script>
|
<script type="text/javascript" src="../dist/diff2html.js"></script>
|
||||||
<script type="text/javascript" src="../dist/diff2html-ui.js"></script>
|
<script type="text/javascript" src="../dist/diff2html-ui.js"></script>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var lineDiffExample =
|
var lineDiffExample =
|
||||||
'diff --git a/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/coverage.init b/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/coverage.init\n' +
|
'diff --git a/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/coverage.init b/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/coverage.init\n' +
|
||||||
'index fc56817..e8e7e49 100644\n' +
|
'index fc56817..e8e7e49 100644\n' +
|
||||||
'--- a/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/coverage.init\n' +
|
'--- a/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/coverage.init\n' +
|
||||||
'+++ b/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/coverage.init\n' +
|
'+++ b/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/src/very/long/file/path/coverage.init\n' +
|
||||||
'@@ -19,7 +19,7 @@\n' +
|
'@@ -19,7 +19,7 @@\n' +
|
||||||
' -opt "\-nostart"\n' +
|
' -opt "\-nostart"\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' # skip stopenv\n' +
|
' # skip stopenv\n' +
|
||||||
'--do "runbvt,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata"\n' +
|
'--do "runbvt,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata,stopenv,getlogs,pullcoveragedata"\n' +
|
||||||
'+-do "runbvt,getlogs,pullcoveragedata"\n' +
|
'+-do "runbvt,getlogs,pullcoveragedata"\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' ##########################################\n' +
|
' ##########################################\n' +
|
||||||
' # logs files to bring back to base\n' +
|
' # logs files to bring back to base\n' +
|
||||||
'diff --git a/src/attributes/attr.js b/src/attributes/attr.js\n' +
|
'diff --git a/src/attributes/attr.js b/src/attributes/attr.js\n' +
|
||||||
'index facdd41..b627fe8 100644\n' +
|
'index facdd41..b627fe8 100644\n' +
|
||||||
'--- a/src/attributes/attr.js\n' +
|
'--- a/src/attributes/attr.js\n' +
|
||||||
'+++ b/src/attributes/attr.js\n' +
|
'+++ b/src/attributes/attr.js\n' +
|
||||||
'@@ -1,11 +1,10 @@\n' +
|
'@@ -1,11 +1,10 @@\n' +
|
||||||
' define([\n' +
|
' define([\n' +
|
||||||
' "../core",\n' +
|
' "../core",\n' +
|
||||||
' "../var/rnotwhite",\n' +
|
' "../var/rnotwhite",\n' +
|
||||||
'- "../var/strundefined",\n' +
|
'- "../var/strundefined",\n' +
|
||||||
' "../core/access",\n' +
|
' "../core/access",\n' +
|
||||||
' "./support",\n' +
|
' "./support",\n' +
|
||||||
' "../selector"\n' +
|
' "../selector"\n' +
|
||||||
'-], function( jQuery, rnotwhite, strundefined, access, support ) {\n' +
|
'-], function( jQuery, rnotwhite, strundefined, access, support ) {\n' +
|
||||||
'+], function( jQuery, rnotwhite, access, support ) {\n' +
|
'+], function( jQuery, rnotwhite, access, support ) {\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' var nodeHook, boolHook,\n' +
|
' var nodeHook, boolHook,\n' +
|
||||||
' attrHandle = jQuery.expr.attrHandle;\n' +
|
' attrHandle = jQuery.expr.attrHandle;\n' +
|
||||||
'@@ -33,7 +32,7 @@ jQuery.extend({\n' +
|
'@@ -33,7 +32,7 @@ jQuery.extend({\n' +
|
||||||
' }\n' +
|
' }\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' // Fallback to prop when attributes are not supported\n' +
|
' // Fallback to prop when attributes are not supported\n' +
|
||||||
'- if ( typeof elem.getAttribute === strundefined ) {\n' +
|
'- if ( typeof elem.getAttribute === strundefined ) {\n' +
|
||||||
'+ if ( !elem.getAttribute ) {\n' +
|
'+ if ( !elem.getAttribute ) {\n' +
|
||||||
' return jQuery.prop( elem, name, value );\n' +
|
' return jQuery.prop( elem, name, value );\n' +
|
||||||
' }\n' +
|
' }\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
'diff --git a/src/attributes/classes.js b/src/attributes/classes.js\n' +
|
'diff --git a/src/attributes/classes.js b/src/attributes/classes.js\n' +
|
||||||
'index c617824..c8d1393 100644\n' +
|
'index c617824..c8d1393 100644\n' +
|
||||||
'--- a/src/attributes/classes.js\n' +
|
'--- a/src/attributes/classes.js\n' +
|
||||||
'+++ b/src/attributes/classes.js\n' +
|
'+++ b/src/attributes/classes.js\n' +
|
||||||
'@@ -1,10 +1,9 @@\n' +
|
'@@ -1,10 +1,9 @@\n' +
|
||||||
' define([\n' +
|
' define([\n' +
|
||||||
' "../core",\n' +
|
' "../core",\n' +
|
||||||
' "../var/rnotwhite",\n' +
|
' "../var/rnotwhite",\n' +
|
||||||
'- "../var/strundefined",\n' +
|
'- "../var/strundefined",\n' +
|
||||||
' "../data/var/dataPriv",\n' +
|
' "../data/var/dataPriv",\n' +
|
||||||
' "../core/init"\n' +
|
' "../core/init"\n' +
|
||||||
'-], function( jQuery, rnotwhite, strundefined, dataPriv ) {\n' +
|
'-], function( jQuery, rnotwhite, strundefined, dataPriv ) {\n' +
|
||||||
'+], function( jQuery, rnotwhite, dataPriv ) {\n' +
|
'+], function( jQuery, rnotwhite, dataPriv ) {\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' var rclass = /[\\t\\r\\n\\f]/g;\n' +
|
' var rclass = /[\\t\\r\\n\\f]/g;\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
'@@ -128,7 +127,7 @@ jQuery.fn.extend({\n' +
|
'@@ -128,7 +127,7 @@ jQuery.fn.extend({\n' +
|
||||||
' }\n' +
|
' }\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' // Toggle whole class name\n' +
|
' // Toggle whole class name\n' +
|
||||||
'- } else if ( type === strundefined || type === "boolean" ) {\n' +
|
'- } else if ( type === strundefined || type === "boolean" ) {\n' +
|
||||||
'+ } else if ( value === undefined || type === "boolean" ) {\n' +
|
'+ } else if ( value === undefined || type === "boolean" ) {\n' +
|
||||||
' if ( this.className ) {\n' +
|
' if ( this.className ) {\n' +
|
||||||
' // store className if set\n' +
|
' // store className if set\n' +
|
||||||
' dataPriv.set( this, "__className__", this.className );\n' +
|
' dataPriv.set( this, "__className__", this.className );\n' +
|
||||||
'diff --git a/src/core/init.js b/src/core/init.js\n' +
|
'diff --git a/src/core/init.js b/src/core/init.js\n' +
|
||||||
'index e49196a..50f310c 100644\n' +
|
'index e49196a..50f310c 100644\n' +
|
||||||
'--- a/src/core/init.js\n' +
|
'--- a/src/core/init.js\n' +
|
||||||
'+++ b/src/core/init.js\n' +
|
'+++ b/src/core/init.js\n' +
|
||||||
'@@ -101,7 +101,7 @@ var rootjQuery,\n' +
|
'@@ -101,7 +101,7 @@ var rootjQuery,\n' +
|
||||||
' // HANDLE: $(function)\n' +
|
' // HANDLE: $(function)\n' +
|
||||||
' // Shortcut for document ready\n' +
|
' // Shortcut for document ready\n' +
|
||||||
' } else if ( jQuery.isFunction( selector ) ) {\n' +
|
' } else if ( jQuery.isFunction( selector ) ) {\n' +
|
||||||
'- return typeof rootjQuery.ready !== "undefined" ?\n' +
|
'- return typeof rootjQuery.ready !== "undefined" ?\n' +
|
||||||
'+ return rootjQuery.ready !== undefined ?\n' +
|
'+ return rootjQuery.ready !== undefined ?\n' +
|
||||||
' rootjQuery.ready( selector ) :\n' +
|
' rootjQuery.ready( selector ) :\n' +
|
||||||
' // Execute immediately if ready is not present\n' +
|
' // Execute immediately if ready is not present\n' +
|
||||||
' selector( jQuery );\n' +
|
' selector( jQuery );\n' +
|
||||||
'diff --git a/src/event.js b/src/event.js\n' +
|
'diff --git a/src/event.js b/src/event.js\n' +
|
||||||
'index 7336f4d..6183f70 100644\n' +
|
'index 7336f4d..6183f70 100644\n' +
|
||||||
'--- a/src/event.js\n' +
|
'--- a/src/event.js\n' +
|
||||||
'+++ b/src/event.js\n' +
|
'+++ b/src/event.js\n' +
|
||||||
'@@ -1,6 +1,5 @@\n' +
|
'@@ -1,6 +1,5 @@\n' +
|
||||||
' define([\n' +
|
' define([\n' +
|
||||||
' "./core",\n' +
|
' "./core",\n' +
|
||||||
'- "./var/strundefined",\n' +
|
'- "./var/strundefined",\n' +
|
||||||
' "./var/rnotwhite",\n' +
|
' "./var/rnotwhite",\n' +
|
||||||
' "./var/hasOwn",\n' +
|
' "./var/hasOwn",\n' +
|
||||||
' "./var/slice",\n' +
|
' "./var/slice",\n' +
|
||||||
'@@ -10,7 +9,7 @@ define([\n' +
|
'@@ -10,7 +9,7 @@ define([\n' +
|
||||||
' "./core/init",\n' +
|
' "./core/init",\n' +
|
||||||
' "./data/accepts",\n' +
|
' "./data/accepts",\n' +
|
||||||
' "./selector"\n' +
|
' "./selector"\n' +
|
||||||
'-], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, dataPriv ) {\n' +
|
'-], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, dataPriv ) {\n' +
|
||||||
'+], function( jQuery, rnotwhite, hasOwn, slice, support, dataPriv ) {\n' +
|
'+], function( jQuery, rnotwhite, hasOwn, slice, support, dataPriv ) {\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' var\n' +
|
' var\n' +
|
||||||
' rkeyEvent = /^key/,\n' +
|
' rkeyEvent = /^key/,\n' +
|
||||||
'@@ -72,7 +71,7 @@ jQuery.event = {\n' +
|
'@@ -72,7 +71,7 @@ jQuery.event = {\n' +
|
||||||
' eventHandle = elemData.handle = function( e ) {\n' +
|
' eventHandle = elemData.handle = function( e ) {\n' +
|
||||||
' // Discard the second event of a jQuery.event.trigger() and\n' +
|
' // Discard the second event of a jQuery.event.trigger() and\n' +
|
||||||
' // when an event is called after a page has unloaded\n' +
|
' // when an event is called after a page has unloaded\n' +
|
||||||
'- return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?\n' +
|
'- return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?\n' +
|
||||||
'+ return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?\n' +
|
'+ return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?\n' +
|
||||||
' jQuery.event.dispatch.apply( elem, arguments ) : undefined;\n' +
|
' jQuery.event.dispatch.apply( elem, arguments ) : undefined;\n' +
|
||||||
' };\n' +
|
' };\n' +
|
||||||
' }\n' +
|
' }\n' +
|
||||||
'diff --git a/src/exports/global.js b/src/exports/global.js\n' +
|
'diff --git a/src/exports/global.js b/src/exports/global.js\n' +
|
||||||
'index 6513287..1db4144 100644\n' +
|
'index 6513287..1db4144 100644\n' +
|
||||||
'--- a/src/exports/global.js\n' +
|
'--- a/src/exports/global.js\n' +
|
||||||
'+++ b/src/exports/global.js\n' +
|
'+++ b/src/exports/global.js\n' +
|
||||||
'@@ -1,7 +1,9 @@\n' +
|
'@@ -1,7 +1,9 @@\n' +
|
||||||
' define([\n' +
|
' define([\n' +
|
||||||
'- "../core",\n' +
|
'- "../core",\n' +
|
||||||
'- "../var/strundefined"\n' +
|
'- "../var/strundefined"\n' +
|
||||||
'-], function( jQuery, strundefined ) {\n' +
|
'-], function( jQuery, strundefined ) {\n' +
|
||||||
'+ "../core"\n' +
|
'+ "../core"\n' +
|
||||||
'+], function( jQuery ) {\n' +
|
'+], function( jQuery ) {\n' +
|
||||||
'+\n' +
|
'+\n' +
|
||||||
'+/* exported noGlobal */\n' +
|
'+/* exported noGlobal */\n' +
|
||||||
'+/* global noGlobal: false */\n' +
|
'+/* global noGlobal: false */\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' var\n' +
|
' var\n' +
|
||||||
' // Map over jQuery in case of overwrite\n' +
|
' // Map over jQuery in case of overwrite\n' +
|
||||||
'@@ -25,7 +27,7 @@ jQuery.noConflict = function( deep ) {\n' +
|
'@@ -25,7 +27,7 @@ jQuery.noConflict = function( deep ) {\n' +
|
||||||
' // Expose jQuery and $ identifiers, even in AMD\n' +
|
' // Expose jQuery and $ identifiers, even in AMD\n' +
|
||||||
' // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)\n' +
|
' // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)\n' +
|
||||||
' // and CommonJS for browser emulators (#13566)\n' +
|
' // and CommonJS for browser emulators (#13566)\n' +
|
||||||
'-if ( typeof noGlobal === strundefined ) {\n' +
|
'-if ( typeof noGlobal === strundefined ) {\n' +
|
||||||
'+if ( !noGlobal ) {\n' +
|
'+if ( !noGlobal ) {\n' +
|
||||||
' window.jQuery = window.$ = jQuery;\n' +
|
' window.jQuery = window.$ = jQuery;\n' +
|
||||||
' }\n' +
|
' }\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
'diff --git a/src/offset.js b/src/offset.js\n' +
|
'diff --git a/src/offset.js b/src/offset.js\n' +
|
||||||
'index cc6ffb4..fa51f18 100644\n' +
|
'index cc6ffb4..fa51f18 100644\n' +
|
||||||
'--- a/src/offset.js\n' +
|
'--- a/src/offset.js\n' +
|
||||||
'+++ b/src/offset.js\n' +
|
'+++ b/src/offset.js\n' +
|
||||||
'@@ -1,6 +1,5 @@\n' +
|
'@@ -1,6 +1,5 @@\n' +
|
||||||
' define([\n' +
|
' define([\n' +
|
||||||
' "./core",\n' +
|
' "./core",\n' +
|
||||||
'- "./var/strundefined",\n' +
|
'- "./var/strundefined",\n' +
|
||||||
' "./core/access",\n' +
|
' "./core/access",\n' +
|
||||||
' "./css/var/rnumnonpx",\n' +
|
' "./css/var/rnumnonpx",\n' +
|
||||||
' "./css/curCSS",\n' +
|
' "./css/curCSS",\n' +
|
||||||
'@@ -10,7 +9,7 @@ define([\n' +
|
'@@ -10,7 +9,7 @@ define([\n' +
|
||||||
' "./core/init",\n' +
|
' "./core/init",\n' +
|
||||||
' "./css",\n' +
|
' "./css",\n' +
|
||||||
' "./selector" // contains\n' +
|
' "./selector" // contains\n' +
|
||||||
'-], function( jQuery, strundefined, access, rnumnonpx, curCSS, addGetHookIf, support ) {\n' +
|
'-], function( jQuery, strundefined, access, rnumnonpx, curCSS, addGetHookIf, support ) {\n' +
|
||||||
'+], function( jQuery, access, rnumnonpx, curCSS, addGetHookIf, support ) {\n' +
|
'+], function( jQuery, access, rnumnonpx, curCSS, addGetHookIf, support ) {\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' var docElem = window.document.documentElement;\n' +
|
' var docElem = window.document.documentElement;\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
'@@ -99,7 +98,7 @@ jQuery.fn.extend({\n' +
|
'@@ -99,7 +98,7 @@ jQuery.fn.extend({\n' +
|
||||||
' \n' +
|
' \n' +
|
||||||
' // Support: BlackBerry 5, iOS 3 (original iPhone)\n' +
|
' // Support: BlackBerry 5, iOS 3 (original iPhone)\n' +
|
||||||
' // If we dont have gBCR, just use 0,0 rather than error\n' +
|
' // If we dont have gBCR, just use 0,0 rather than error\n' +
|
||||||
'- if ( typeof elem.getBoundingClientRect !== strundefined ) {\n' +
|
'- if ( typeof elem.getBoundingClientRect !== strundefined ) {\n' +
|
||||||
'+ if ( elem.getBoundingClientRect !== undefined ) {\n' +
|
'+ if ( elem.getBoundingClientRect !== undefined ) {\n' +
|
||||||
' box = elem.getBoundingClientRect();\n' +
|
' box = elem.getBoundingClientRect();\n' +
|
||||||
' }\n' +
|
' }\n' +
|
||||||
' win = getWindow( doc );\n' +
|
' win = getWindow( doc );\n' +
|
||||||
'diff --git a/src/var/strundefined.js b/src/var/strundefined.js\n' +
|
'diff --git a/src/var/strundefined.js b/src/var/strundefined.js\n' +
|
||||||
'deleted file mode 100644\n' +
|
'deleted file mode 100644\n' +
|
||||||
'index 04e16b0..0000000\n' +
|
'index 04e16b0..0000000\n' +
|
||||||
'--- a/src/var/strundefined.js\n' +
|
'--- a/src/var/strundefined.js\n' +
|
||||||
'+++ /dev/null\n' +
|
'+++ /dev/null\n' +
|
||||||
'@@ -1,3 +0,0 @@\n' +
|
'@@ -1,3 +0,0 @@\n' +
|
||||||
'-define(function() {\n' +
|
'-define(function() {\n' +
|
||||||
'- return typeof undefined;\n' +
|
'- return typeof undefined;\n' +
|
||||||
'-});\n' +
|
'-});\n' +
|
||||||
'diff --git a/components/textdiff/textdiff.html b/components/textdiff/textdiff.html\n' +
|
'diff --git a/components/textdiff/textdiff.html b/components/textdiff/textdiff.html\n' +
|
||||||
'index a3484bf..82209af 100644\n' +
|
'index a3484bf..82209af 100644\n' +
|
||||||
'--- a/components/textdiff/textdiff.html\n' +
|
'--- a/components/textdiff/textdiff.html\n' +
|
||||||
'+++ b/components/textdiff/textdiff.html\n' +
|
'+++ b/components/textdiff/textdiff.html\n' +
|
||||||
'@@ -1,6 +1,8 @@\n' +
|
'@@ -1,6 +1,8 @@\n' +
|
||||||
' <!-- ko if: isShowingDiffs -->\n' +
|
' <!-- ko if: isShowingDiffs -->\n' +
|
||||||
' <div>\n' +
|
' <div>\n' +
|
||||||
'- <div data-bind="event: { load: setDom($element) }"></div>\n' +
|
'- <div data-bind="event: { load: setDom($element) }"></div>\n' +
|
||||||
'+ <!-- ko if: isParsed -->\n' +
|
'+ <!-- ko if: isParsed -->\n' +
|
||||||
'+ <div data-bind="template: {nodes: ko.utils.parseHtmlFragment(htmlSrc())}"></div>\n' +
|
'+ <div data-bind="template: {nodes: ko.utils.parseHtmlFragment(htmlSrc())}"></div>\n' +
|
||||||
'+ <!-- /ko -->\n' +
|
'+ <!-- /ko -->\n' +
|
||||||
' <div class="btn-load-more" data-bind="visible: loadMoreCount() > 0">\n' +
|
' <div class="btn-load-more" data-bind="visible: loadMoreCount() > 0">\n' +
|
||||||
' </div>\n' +
|
' </div>\n' +
|
||||||
'diff --git a/test.js b/test.js\n' +
|
'diff --git a/test.js b/test.js\n' +
|
||||||
'new file mode 100644\n' +
|
'new file mode 100644\n' +
|
||||||
'index 0000000..e1e22ec\n' +
|
'index 0000000..e1e22ec\n' +
|
||||||
'--- /dev/null\n' +
|
'--- /dev/null\n' +
|
||||||
'+++ b/test.js\n' +
|
'+++ b/test.js\n' +
|
||||||
'@@ -0,0 +1,6 @@\n' +
|
'@@ -0,0 +1,6 @@\n' +
|
||||||
"+var parser = require('./source/git-parser');\n" +
|
"+var parser = require('./source/git-parser');\n" +
|
||||||
'+\n' +
|
'+\n' +
|
||||||
"+var text = 'diff --git a/components/app/app.html b/components/app/app.html\\nindex ecb7a95..027bd9b 100644\\n--- a/components/app/app.html\\n+++ b/components/app/app.html\\n@@ -52,0 +53,3 @@\\n+\\n+\\n+\\n@@ -56,0 +60,3 @@\\n+\\n+\\n+\\n'\n" +
|
"+var text = 'diff --git a/components/app/app.html b/components/app/app.html\\nindex ecb7a95..027bd9b 100644\\n--- a/components/app/app.html\\n+++ b/components/app/app.html\\n@@ -52,0 +53,3 @@\\n+\\n+\\n+\\n@@ -56,0 +60,3 @@\\n+\\n+\\n+\\n'\n" +
|
||||||
'+var patchLineList = [ false, false, false, false ];\n' +
|
'+var patchLineList = [ false, false, false, false ];\n' +
|
||||||
'+\n' +
|
'+\n' +
|
||||||
'+console.log(parser.parsePatchDiffResult(text, patchLineList));\n' +
|
'+console.log(parser.parsePatchDiffResult(text, patchLineList));\n' +
|
||||||
"diff --git a/a.xml b/b.xml\n" +
|
"diff --git a/a.xml b/b.xml\n" +
|
||||||
"index e54317e..82a9a56 100644\n" +
|
"index e54317e..82a9a56 100644\n" +
|
||||||
"--- a/a.xml\n" +
|
"--- a/a.xml\n" +
|
||||||
"+++ b/b.xml\n" +
|
"+++ b/b.xml\n" +
|
||||||
"@@ -242,4 +242,6 @@ need to create a new job for native server java api and move these tests to a ne\n" +
|
"@@ -242,4 +242,6 @@ need to create a new job for native server java api and move these tests to a ne\n" +
|
||||||
" </packages>\n" +
|
" </packages>\n" +
|
||||||
" </test>\n" +
|
" </test>\n" +
|
||||||
" -->\n" +
|
" -->\n" +
|
||||||
"+\n" +
|
"+\n" +
|
||||||
"+\n";
|
"+\n" +
|
||||||
|
"--- a/sample.js\n" +
|
||||||
|
"+++ b/sample.js\n" +
|
||||||
|
"@@ -1 +1,2 @@\n" +
|
||||||
|
"-test\n" +
|
||||||
|
"+test1r\n" +
|
||||||
|
"+test2r\n";
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var diff2htmlUi = new Diff2HtmlUI({diff: lineDiffExample});
|
var diff2htmlUi = new Diff2HtmlUI({diff: lineDiffExample});
|
||||||
|
|
||||||
diff2htmlUi.draw('#line-by-line', {inputFormat: 'json', showFiles: true, matching: 'lines'});
|
diff2htmlUi.draw('#line-by-line', {inputFormat: 'json', showFiles: true, matching: 'lines'});
|
||||||
diff2htmlUi.fileListCloseable('#line-by-line', false);
|
diff2htmlUi.fileListCloseable('#line-by-line', false);
|
||||||
diff2htmlUi.highlightCode('#line-by-line');
|
diff2htmlUi.highlightCode('#line-by-line');
|
||||||
|
|
||||||
diff2htmlUi.draw('#side-by-side', {
|
diff2htmlUi.draw('#side-by-side', {
|
||||||
inputFormat: 'json',
|
inputFormat: 'json',
|
||||||
showFiles: true,
|
showFiles: true,
|
||||||
matching: 'lines',
|
matching: 'lines',
|
||||||
outputFormat: 'side-by-side'
|
outputFormat: 'side-by-side'
|
||||||
});
|
});
|
||||||
diff2htmlUi.fileListCloseable('#side-by-side', false);
|
diff2htmlUi.fileListCloseable('#side-by-side', false);
|
||||||
diff2htmlUi.highlightCode('#side-by-side');
|
diff2htmlUi.highlightCode('#side-by-side');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body style="text-align: center; font-family: 'Source Sans Pro',sans-serif;">
|
<body style="text-align: center; font-family: 'Source Sans Pro',sans-serif;">
|
||||||
|
|
|
||||||
|
|
@ -33,32 +33,30 @@
|
||||||
var oldLine2 = null; // Used for combined diff
|
var oldLine2 = null; // Used for combined diff
|
||||||
var newLine = null;
|
var newLine = null;
|
||||||
|
|
||||||
|
/* Add previous block(if exists) before start a new file */
|
||||||
var saveBlock = function() {
|
var saveBlock = function() {
|
||||||
|
|
||||||
/* Add previous block(if exists) before start a new file */
|
|
||||||
if (currentBlock) {
|
if (currentBlock) {
|
||||||
currentFile.blocks.push(currentBlock);
|
currentFile.blocks.push(currentBlock);
|
||||||
currentBlock = null;
|
currentBlock = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add previous file(if exists) before start a new one
|
||||||
|
* if it has name (to avoid binary files errors)
|
||||||
|
*/
|
||||||
var saveFile = function() {
|
var saveFile = function() {
|
||||||
|
|
||||||
/*
|
|
||||||
* Add previous file(if exists) before start a new one
|
|
||||||
* if it has name (to avoid binary files errors)
|
|
||||||
*/
|
|
||||||
if (currentFile && currentFile.newName) {
|
if (currentFile && currentFile.newName) {
|
||||||
files.push(currentFile);
|
files.push(currentFile);
|
||||||
currentFile = null;
|
currentFile = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Create file structure */
|
||||||
var startFile = function() {
|
var startFile = function() {
|
||||||
saveBlock();
|
saveBlock();
|
||||||
saveFile();
|
saveFile();
|
||||||
|
|
||||||
/* Create file structure */
|
|
||||||
currentFile = {};
|
currentFile = {};
|
||||||
currentFile.blocks = [];
|
currentFile.blocks = [];
|
||||||
currentFile.deletedLines = 0;
|
currentFile.deletedLines = 0;
|
||||||
|
|
@ -179,18 +177,72 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var values = [];
|
if (
|
||||||
if (utils.startsWith(line, 'diff')) {
|
utils.startsWith(line, 'diff') || // Git diffs always start with diff
|
||||||
|
!currentFile || // If we do not have a file yet, we should crete one
|
||||||
|
(
|
||||||
|
currentFile && // If we already have some file in progress and
|
||||||
|
(
|
||||||
|
currentFile.oldName && utils.startsWith(line, '---') || // Either we reached a old file identification line
|
||||||
|
currentFile.newName && utils.startsWith(line, '+++') // Or we reached a new file identification line
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
startFile();
|
startFile();
|
||||||
} else if (currentFile && !currentFile.oldName && (values = getSrcFilename(line, config))) {
|
}
|
||||||
|
|
||||||
|
var values;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* --- Date Timestamp[FractionalSeconds] TimeZone
|
||||||
|
* --- 2002-02-21 23:30:39.942229878 -0800
|
||||||
|
*/
|
||||||
|
if (currentFile && !currentFile.oldName &&
|
||||||
|
utils.startsWith(line, '---') && (values = getSrcFilename(line, config))) {
|
||||||
currentFile.oldName = values;
|
currentFile.oldName = values;
|
||||||
currentFile.language = getExtension(currentFile.oldName, currentFile.language);
|
currentFile.language = getExtension(currentFile.oldName, currentFile.language);
|
||||||
} else if (currentFile && !currentFile.newName && (values = getDstFilename(line, config))) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* +++ Date Timestamp[FractionalSeconds] TimeZone
|
||||||
|
* +++ 2002-02-21 23:30:39.942229878 -0800
|
||||||
|
*/
|
||||||
|
if (currentFile && !currentFile.newName &&
|
||||||
|
utils.startsWith(line, '+++') && (values = getDstFilename(line, config))) {
|
||||||
currentFile.newName = values;
|
currentFile.newName = values;
|
||||||
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
currentFile.language = getExtension(currentFile.newName, currentFile.language);
|
||||||
} else if (currentFile && utils.startsWith(line, '@@')) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentFile && utils.startsWith(line, '@')) {
|
||||||
startBlock(line);
|
startBlock(line);
|
||||||
} else if ((values = oldMode.exec(line))) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There are three types of diff lines. These lines are defined by the way they start.
|
||||||
|
* 1. New line starts with: +
|
||||||
|
* 2. Old line starts with: -
|
||||||
|
* 3. Context line starts with: <SPACE>
|
||||||
|
*/
|
||||||
|
if (currentBlock && (utils.startsWith(line, '+') || utils.startsWith(line, '-') || utils.startsWith(line, ' '))) {
|
||||||
|
createLine(line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(currentFile && currentFile.blocks.length) ||
|
||||||
|
(currentBlock && currentBlock.lines.length)
|
||||||
|
) {
|
||||||
|
startFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Git diffs provide more information regarding files modes, renames, copies,
|
||||||
|
* commits between changes and similarity indexes
|
||||||
|
*/
|
||||||
|
if ((values = oldMode.exec(line))) {
|
||||||
currentFile.oldMode = values[1];
|
currentFile.oldMode = values[1];
|
||||||
} else if ((values = newMode.exec(line))) {
|
} else if ((values = newMode.exec(line))) {
|
||||||
currentFile.newMode = values[1];
|
currentFile.newMode = values[1];
|
||||||
|
|
@ -232,8 +284,6 @@
|
||||||
} else if ((values = combinedDeletedFile.exec(line))) {
|
} else if ((values = combinedDeletedFile.exec(line))) {
|
||||||
currentFile.deletedFileMode = values[1];
|
currentFile.deletedFileMode = values[1];
|
||||||
currentFile.isDeleted = true;
|
currentFile.isDeleted = true;
|
||||||
} else if (currentBlock) {
|
|
||||||
createLine(line);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ describe('DiffParser', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkDiffSample(diff) {
|
function checkDiffSample(diff) {
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
assert.equal(1, file1.addedLines);
|
assert.equal(1, file1.addedLines);
|
||||||
|
|
@ -75,7 +75,7 @@ describe('DiffParser', function() {
|
||||||
'+cenas com ananas\n' +
|
'+cenas com ananas\n' +
|
||||||
'+bananas';
|
'+bananas';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
assert.equal(2, file1.addedLines);
|
assert.equal(2, file1.addedLines);
|
||||||
|
|
@ -96,7 +96,7 @@ describe('DiffParser', function() {
|
||||||
'+cenas com ananas\n' +
|
'+cenas com ananas\n' +
|
||||||
'+bananas';
|
'+bananas';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff, {"srcPrefix": "\t", "dstPrefix": "\t"});
|
var result = DiffParser.generateDiffJson(diff, {"srcPrefix": "\t", "dstPrefix": "\t"});
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
assert.equal(2, file1.addedLines);
|
assert.equal(2, file1.addedLines);
|
||||||
|
|
@ -118,7 +118,7 @@ describe('DiffParser', function() {
|
||||||
'- return typeof undefined;\n' +
|
'- return typeof undefined;\n' +
|
||||||
'-});\n';
|
'-});\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -147,7 +147,7 @@ describe('DiffParser', function() {
|
||||||
'+\n' +
|
'+\n' +
|
||||||
'+console.log(parser.parsePatchDiffResult(text, patchLineList));\n';
|
'+console.log(parser.parsePatchDiffResult(text, patchLineList));\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -177,7 +177,7 @@ describe('DiffParser', function() {
|
||||||
'+\n' +
|
'+\n' +
|
||||||
'+console.log(parser.parsePatchDiffResult(text, patchLineList));\n';
|
'+console.log(parser.parsePatchDiffResult(text, patchLineList));\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -220,7 +220,7 @@ describe('DiffParser', function() {
|
||||||
' // store className if set\n' +
|
' // store className if set\n' +
|
||||||
' dataPriv.set( this, "__className__", this.className );\n';
|
' dataPriv.set( this, "__className__", this.className );\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -263,7 +263,7 @@ describe('DiffParser', function() {
|
||||||
' "./var/hasOwn",\n' +
|
' "./var/hasOwn",\n' +
|
||||||
' "./var/slice",\n';
|
' "./var/slice",\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(2, result.length);
|
assert.equal(2, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -319,7 +319,7 @@ describe('DiffParser', function() {
|
||||||
' initialized = 1;\n' +
|
' initialized = 1;\n' +
|
||||||
' for_each_ref(get_name);\n';
|
' for_each_ref(get_name);\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -341,7 +341,7 @@ describe('DiffParser', function() {
|
||||||
'copy from index.js\n' +
|
'copy from index.js\n' +
|
||||||
'copy to more-index.js\n';
|
'copy to more-index.js\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -361,7 +361,7 @@ describe('DiffParser', function() {
|
||||||
'rename from more-index.js\n' +
|
'rename from more-index.js\n' +
|
||||||
'rename to other-index.js\n';
|
'rename to other-index.js\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -384,7 +384,7 @@ describe('DiffParser', function() {
|
||||||
'-test\n' +
|
'-test\n' +
|
||||||
'+test1r\n';
|
'+test1r\n';
|
||||||
|
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
|
|
@ -400,5 +400,29 @@ describe('DiffParser', function() {
|
||||||
assert.equal(1, file1.blocks[0].lines[1].newNumber);
|
assert.equal(1, file1.blocks[0].lines[1].newNumber);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse unified non git diff', function() {
|
||||||
|
var diff =
|
||||||
|
'--- a/sample.js\n' +
|
||||||
|
'+++ b/sample.js\n' +
|
||||||
|
'@@ -1 +1,2 @@\n' +
|
||||||
|
'-test\n' +
|
||||||
|
'+test1r\n' +
|
||||||
|
'+test2r\n';
|
||||||
|
|
||||||
|
var result = DiffParser.generateDiffJson(diff);
|
||||||
|
var file1 = result[0];
|
||||||
|
assert.equal(1, result.length);
|
||||||
|
assert.equal(2, file1.addedLines);
|
||||||
|
assert.equal(1, file1.deletedLines);
|
||||||
|
assert.equal('sample.js', file1.oldName);
|
||||||
|
assert.equal('sample.js', file1.newName);
|
||||||
|
assert.equal(1, file1.blocks.length);
|
||||||
|
|
||||||
|
var linesContent = file1.blocks[0].lines.map(function(line) {
|
||||||
|
return line.content;
|
||||||
|
});
|
||||||
|
assert.deepEqual(linesContent, ['-test', '+test1r', '+test2r']);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,6 @@ describe('Diff2Html', function() {
|
||||||
'+test1\n';
|
'+test1\n';
|
||||||
var result = Diff2Html.getJsonFromDiff(diff);
|
var result = Diff2Html.getJsonFromDiff(diff);
|
||||||
|
|
||||||
console.log(result);
|
|
||||||
var file1 = result[0];
|
var file1 = result[0];
|
||||||
assert.equal(1, result.length);
|
assert.equal(1, result.length);
|
||||||
assert.equal(1, file1.addedLines);
|
assert.equal(1, file1.addedLines);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue