1 | /*
|
2 | Language: Diff
|
3 | Description: Unified and context diff
|
4 | Author: Vasily Polovnyov <vast@whiteants.net>
|
5 | Website: https://www.gnu.org/software/diffutils/
|
6 | Category: common
|
7 | */
|
8 |
|
9 | /** @type LanguageFn */
|
10 | function 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 |
|
64 | export { diff as default };
|