UNPKG

1.23 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 {
41 match: /^\*{15}$/
42 }
43 ]
44 },
45 {
46 className: 'addition',
47 begin: /^\+/,
48 end: /$/
49 },
50 {
51 className: 'deletion',
52 begin: /^-/,
53 end: /$/
54 },
55 {
56 className: 'addition',
57 begin: /^!/,
58 end: /$/
59 }
60 ]
61 };
62}
63
64export { diff as default };