aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/utilities/highlight-json5.tid
blob: fae9bd4a5540c0b6087a8aa07879a0985695eb73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
title: $:/plugins/local/highlight-languages/json5.js
type: application/javascript
module-type: highlight

/*\
title: $:/plugins/local/highlight-languages/json5.js
type: application/javascript
module-type: highlight

JSON5 language definition for highlight.js.
\*/
"use strict";

hljs.registerLanguage("json5",function(hljs) {
	return {
		name: "JSON5",
		aliases: ["json5"],
		keywords: {
			literal: "true false null"
		},
		contains: [
			hljs.C_LINE_COMMENT_MODE,
			hljs.C_BLOCK_COMMENT_MODE,
			{
				className: "attr",
				match: /[A-Za-z_$][0-9A-Za-z_$]*(?=\s*:)/
			},
			{
				className: "attr",
				match: /"(?:\\.|[^"\\\r\n])*"(?=\s*:)/
			},
			{
				className: "attr",
				match: /'(?:\\.|[^'\\\r\n])*'(?=\s*:)/
			},
			hljs.QUOTE_STRING_MODE,
			hljs.APOS_STRING_MODE,
			{
				className: "number",
				variants: [
					{
						begin: /[+-]?(?:Infinity|NaN)\b/
					},
					{
						begin: /[+-]?0[xX][0-9a-fA-F]+\b/
					},
					{
						begin: /[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/
					}
				],
				relevance: 0
			},
			{
				className: "punctuation",
				match: /[{}\[\],:]/
			}
		]
	};
});