diff --git a/components/prism-git.js b/components/prism-git.js index 0d2ecb1c12..e5cc4cefce 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) @@ -48,12 +54,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: diff --git a/components/prism-git.min.js b/components/prism-git.min.js index 44468b9408..e4b5da4796 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 3c75cca195..b93fb1812c 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", "+"] ] ----------------------------------------------------