-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
nginx.js
60 lines (58 loc) · 1.5 KB
/
nginx.js
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
// @ts-nocheck
nginx.displayName = 'nginx'
nginx.aliases = []
/** @type {import('../core.js').Syntax} */
export default function nginx(Prism) {
;(function (Prism) {
var variable =
/\$(?:\w[a-z\d]*(?:_[^\x00-\x1F\s"'\\()$]*)?|\{[^}\s"'\\]+\})/i
Prism.languages.nginx = {
comment: {
pattern: /(^|[\s{};])#.*/,
lookbehind: true,
greedy: true
},
directive: {
pattern:
/(^|\s)\w(?:[^;{}"'\\\s]|\\.|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\s+(?:#.*(?!.)|(?![#\s])))*?(?=\s*[;{])/,
lookbehind: true,
greedy: true,
inside: {
string: {
pattern:
/((?:^|[^\\])(?:\\\\)*)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,
lookbehind: true,
greedy: true,
inside: {
escape: {
pattern: /\\["'\\nrt]/,
alias: 'entity'
},
variable: variable
}
},
comment: {
pattern: /(\s)#.*/,
lookbehind: true,
greedy: true
},
keyword: {
pattern: /^\S+/,
greedy: true
},
// other patterns
boolean: {
pattern: /(\s)(?:off|on)(?!\S)/,
lookbehind: true
},
number: {
pattern: /(\s)\d+[a-z]*(?!\S)/i,
lookbehind: true
},
variable: variable
}
},
punctuation: /[{};]/
}
})(Prism)
}