UNPKG

1.21 kBJavaScriptView Raw
1/*
2Language: Diff
3Description: Unified and context diff
4Author: Vasily Polovnyov <vast@whiteants.net>
5Website: https://www.gnu.org/software/diffutils/
6Category: common
7*/
8
9/** @type LanguageFn */
10function diff(hljs) {
11 const regex = hljs.regex;
12 return {
13 name: 'Diff',
14 aliases: [ 'patch' ],
15 contains: [
16 {
17 className: 'meta',
18 relevance: 10,
19 match: regex.either(
20 /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,
21 /^\*\*\* +\d+,\d+ +\*\*\*\*$/,
22 /^--- +\d+,\d+ +----$/
23 )
24 },
25 {
26 className: 'comment',
27 variants: [
28 {
29 begin: regex.either(
30 /Index: /,
31 /^index/,
32 /={3,}/,
33 /^-{3}/,
34 /^\*{3} /,
35 /^\+{3}/,
36 /^diff --git/
37 ),
38 end: /$/
39 },
40 { match: /^\*{15}$/ }
41 ]
42 },
43 {
44 className: 'addition',
45 begin: /^\+/,
46 end: /$/
47 },
48 {
49 className: 'deletion',
50 begin: /^-/,
51 end: /$/
52 },
53 {
54 className: 'addition',
55 begin: /^!/,
56 end: /$/
57 }
58 ]
59 };
60}
61
62module.exports = diff;