Commit 3aadd5d96b4ff6b3ee348abf0cb7e130bad76445

Golmote 2015-09-14T23:07:03

Git: Add support for unified diff. Fixes #769, fixes #357, closes #401

diff --git a/components/prism-git.js b/components/prism-git.js
index 0d2ecb1..e5cc4ce 100644
--- a/components/prism-git.js
+++ b/components/prism-git.js
@@ -8,7 +8,13 @@ Prism.languages.git = {
 	 * # and have 1 and 2 different commits each, respectively.
 	 * nothing to commit (working directory clean)
 	 */
-	'comment': /^#.*$/m,
+	'comment': /^#.*/m,
+
+	/*
+	 * Regexp to match the changed lines in a git diff output. Check the example below.
+	 */
+	'deleted': /^[-–].*/m,
+	'inserted': /^\+.*/m,
 
 	/*
 	 * a string (double and simple quote)
@@ -49,12 +55,6 @@ Prism.languages.git = {
 	'coord': /^@@.*@@$/m,
 
 	/*
-	 * Regexp to match the changed lines in a git diff output. Check the example above.
-	 */
-	'deleted': /^-(?!-).+$/m,
-	'inserted': /^\+(?!\+).+$/m,
-
-	/*
 	 * Match a "commit [SHA1]" line in a git log output.
 	 * For instance:
 	 * $ git log
diff --git a/components/prism-git.min.js b/components/prism-git.min.js
index 44468b9..e4b5da4 100644
--- a/components/prism-git.min.js
+++ b/components/prism-git.min.js
@@ -1 +1 @@
-Prism.languages.git={comment:/^#.*$/m,string:/("|')(\\?.)*?\1/m,command:{pattern:/^.*\$ git .*$/m,inside:{parameter:/\s(--|-)\w+/m}},coord:/^@@.*@@$/m,deleted:/^-(?!-).+$/m,inserted:/^\+(?!\+).+$/m,commit_sha1:/^commit \w{40}$/m};
\ No newline at end of file
+Prism.languages.git={comment:/^#.*/m,deleted:/^[-–].*/m,inserted:/^\+.*/m,string:/("|')(\\?.)*?\1/m,command:{pattern:/^.*\$ git .*$/m,inside:{parameter:/\s(--|-)\w+/m}},coord:/^@@.*@@$/m,commit_sha1:/^commit \w{40}$/m};
\ No newline at end of file
diff --git a/tests/languages/git/diff_feature.test b/tests/languages/git/diff_feature.test
index 3c75cca..b93fb18 100644
--- a/tests/languages/git/diff_feature.test
+++ b/tests/languages/git/diff_feature.test
@@ -2,12 +2,28 @@
 +Here's my text file
 +And this is the second line
 
+––– a/web/js/lazy.js
++++ b/web/js/lazy.js
+
+-      if (url !== null && url !== '' && typeof url !== 'undefined') {
++      if (url === null || url === '' || typeof url === 'undefined') {
++        return;
++      }
++
+
 ----------------------------------------------------
 
 [
 	["deleted", "-Here's my tetx file"],
 	["inserted", "+Here's my text file"],
-	["inserted", "+And this is the second line"]
+	["inserted", "+And this is the second line"],
+	["deleted", "––– a/web/js/lazy.js"],
+	["inserted", "+++ b/web/js/lazy.js"],
+	["deleted", "-      if (url !== null && url !== '' && typeof url !== 'undefined') {"],
+	["inserted", "+      if (url === null || url === '' || typeof url === 'undefined') {"],
+	["inserted", "+        return;"],
+	["inserted", "+      }"],
+	["inserted", "+"]
 ]
 
 ----------------------------------------------------