comparison third_party/highlight/es/languages/diff.js @ 157:2db6253f355d

[ThirdParty] Added highlight library for better readability on blog.
author June Park <parkjune1995@gmail.com>
date Tue, 13 Jan 2026 19:18:47 -0800
parents
children
comparison
equal deleted inserted replaced
156:cd35e600ae34 157:2db6253f355d
1 /*! `diff` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Diff
7 Description: Unified and context diff
8 Author: Vasily Polovnyov <[email protected]>
9 Website: https://www.gnu.org/software/diffutils/
10 Category: common
11 */
12
13 /** @type LanguageFn */
14 function diff(hljs) {
15 const regex = hljs.regex;
16 return {
17 name: 'Diff',
18 aliases: [ 'patch' ],
19 contains: [
20 {
21 className: 'meta',
22 relevance: 10,
23 match: regex.either(
24 /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,
25 /^\*\*\* +\d+,\d+ +\*\*\*\*$/,
26 /^--- +\d+,\d+ +----$/
27 )
28 },
29 {
30 className: 'comment',
31 variants: [
32 {
33 begin: regex.either(
34 /Index: /,
35 /^index/,
36 /={3,}/,
37 /^-{3}/,
38 /^\*{3} /,
39 /^\+{3}/,
40 /^diff --git/
41 ),
42 end: /$/
43 },
44 { match: /^\*{15}$/ }
45 ]
46 },
47 {
48 className: 'addition',
49 begin: /^\+/,
50 end: /$/
51 },
52 {
53 className: 'deletion',
54 begin: /^-/,
55 end: /$/
56 },
57 {
58 className: 'addition',
59 begin: /^!/,
60 end: /$/
61 }
62 ]
63 };
64 }
65
66 return diff;
67
68 })();
69 ;
70 export default hljsGrammar;