comparison third_party/highlight/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 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Diff
8 Description: Unified and context diff
9 Author: Vasily Polovnyov <[email protected]>
10 Website: https://www.gnu.org/software/diffutils/
11 Category: common
12 */
13
14 /** @type LanguageFn */
15 function diff(hljs) {
16 const regex = hljs.regex;
17 return {
18 name: 'Diff',
19 aliases: [ 'patch' ],
20 contains: [
21 {
22 className: 'meta',
23 relevance: 10,
24 match: regex.either(
25 /^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,
26 /^\*\*\* +\d+,\d+ +\*\*\*\*$/,
27 /^--- +\d+,\d+ +----$/
28 )
29 },
30 {
31 className: 'comment',
32 variants: [
33 {
34 begin: regex.either(
35 /Index: /,
36 /^index/,
37 /={3,}/,
38 /^-{3}/,
39 /^\*{3} /,
40 /^\+{3}/,
41 /^diff --git/
42 ),
43 end: /$/
44 },
45 { match: /^\*{15}$/ }
46 ]
47 },
48 {
49 className: 'addition',
50 begin: /^\+/,
51 end: /$/
52 },
53 {
54 className: 'deletion',
55 begin: /^-/,
56 end: /$/
57 },
58 {
59 className: 'addition',
60 begin: /^!/,
61 end: /$/
62 }
63 ]
64 };
65 }
66
67 return diff;
68
69 })();
70
71 hljs.registerLanguage('diff', hljsGrammar);
72 })();