diff --git a/CHANGES.md b/CHANGES.md index e0b3e0ab7a..84ca31ce9e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,12 +8,14 @@ Core Grammars: - enh(csp) add missing directives / keywords from MDN (7 more) [Max Liashuk][] - enh(ada) add new `parallel` keyword, allow `[]` for Ada 2022 [Max Reznik][] +- fix(diff) fix unified diff hunk header regex to allow unpaired numbers [Chris Wilson][] CONTRIBUTORS [Josh Marchand]: https://github.com/yHSJ [Max Liashuk]: https://github.com/probil [Max Reznik]: https://github.com/reznikmm +[Chris Wilson]: https://github.com/sushicw ## Version 11.11.1 diff --git a/src/languages/diff.js b/src/languages/diff.js index ed7161f3be..4870556f6b 100644 --- a/src/languages/diff.js +++ b/src/languages/diff.js @@ -17,7 +17,10 @@ export default function(hljs) { className: 'meta', relevance: 10, match: regex.either( - /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/, + /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/, // @@ -1,2 +1,2 @@ + /^@@ +-\d+ +\+\d+,\d+ +@@/, // @@ -1 +1,2 @@ + /^@@ +-\d+,\d+ +\+\d+ +@@/, // @@ -1,2 +1 @@ + /^@@ +-\d+ +\+\d+ +@@/, // @@ -1 +1 @@ /^\*\*\* +\d+,\d+ +\*\*\*\*$/, /^--- +\d+,\d+ +----$/ ) diff --git a/test/markup/diff/git-format-patch.expect.txt b/test/markup/diff/git-format-patch.expect.txt index ab02ee1838..12b4eee485 100644 --- a/test/markup/diff/git-format-patch.expect.txt +++ b/test/markup/diff/git-format-patch.expect.txt @@ -12,3 +12,26 @@ @@ -28,2 +28,2 @@ - removal + addition +diff --git a/file.txt b/file.txt +index 8baef1b..24c5735 100644 +--- a/file.txt ++++ b/file.txt +@@ -1 +1 @@ +-removal ++addition +diff --git a/file.txt b/file.txt +index f9308d8..f39c17d 100644 +--- a/file.txt ++++ b/file.txt +@@ -1,2 +1 @@ +-removal1 +-removal2 ++addition +diff --git a/file.txt b/file.txt +index 1037b05..54addbd 100644 +--- a/file.txt ++++ b/file.txt +@@ -1 +1,2 @@ +-removal ++addition1 ++addition2 diff --git a/test/markup/diff/git-format-patch.txt b/test/markup/diff/git-format-patch.txt index 8b5ab0c5d0..ad81fe6d14 100644 --- a/test/markup/diff/git-format-patch.txt +++ b/test/markup/diff/git-format-patch.txt @@ -12,3 +12,26 @@ index 123456..789abc 100644 @@ -28,2 +28,2 @@ - removal + addition +diff --git a/file.txt b/file.txt +index 8baef1b..24c5735 100644 +--- a/file.txt ++++ b/file.txt +@@ -1 +1 @@ +-removal ++addition +diff --git a/file.txt b/file.txt +index f9308d8..f39c17d 100644 +--- a/file.txt ++++ b/file.txt +@@ -1,2 +1 @@ +-removal1 +-removal2 ++addition +diff --git a/file.txt b/file.txt +index 1037b05..54addbd 100644 +--- a/file.txt ++++ b/file.txt +@@ -1 +1,2 @@ +-removal ++addition1 ++addition2