aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/utilities/highlight-caddyfile.tid
blob: 8427c3fe5c9ee47858126ccc63c8603b2b2e05cf (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
60
61
62
63
64
65
tiddlers/highlight-caddyfile.tid
title: $:/plugins/local/highlight-languages/caddyfile.js
type: application/javascript
module-type: highlight

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

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

hljs.registerLanguage("caddyfile",function(hljs) {
	return {
		name: "Caddyfile",
		aliases: ["caddy"],
		case_insensitive: true,
		contains: [
			{
				className: "comment",
				begin: /#/,
				end: /$/
			},
			{
				className: "section",
				begin: /^\s*(?=[^#\n{]*(?:[.:,]|\blocalhost\b))(?:https?:\/\/)?[^\s#{}]+(?:\s*,\s*[^\s#{}]+)*(?=\s*\{?\s*$)/,
				relevance: 10
			},
			{
				className: "keyword",
				begin: /^\s*[A-Za-z_][A-Za-z0-9_-]*(?=\s|$)/,
				relevance: 1
			},
			{
				className: "meta",
				match: /@[A-Za-z0-9_-]+/
			},
			{
				className: "variable",
				match: /\{\$?[A-Za-z_][A-Za-z0-9_.\-[\]*]*\}/
			},
			{
				className: "title",
				match: /\([A-Za-z_][A-Za-z0-9_-]*\)/
			},
			hljs.QUOTE_STRING_MODE,
			hljs.APOS_STRING_MODE,
			{
				className: "literal",
				match: /\b(?:true|false|on|off)\b/
			},
			{
				className: "number",
				match: /\b\d+(?:\.\d+)?(?:ns|us|ms|s|m|h|d|kb|mb|gb|tb)?\b/i,
				relevance: 0
			},
			{
				className: "punctuation",
				match: /[{}]/
			}
		]
	};
});