main
Last change
on this file since 65b6638 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
2.9 KB
|
Line | |
---|
1 | /*
|
---|
2 | Language: Nginx config
|
---|
3 | Author: Peter Leonov <gojpeg@yandex.ru>
|
---|
4 | Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
|
---|
5 | Category: common, config
|
---|
6 | Website: https://www.nginx.com
|
---|
7 | */
|
---|
8 |
|
---|
9 | function nginx(hljs) {
|
---|
10 | const VAR = {
|
---|
11 | className: 'variable',
|
---|
12 | variants: [
|
---|
13 | {
|
---|
14 | begin: /\$\d+/
|
---|
15 | },
|
---|
16 | {
|
---|
17 | begin: /\$\{/,
|
---|
18 | end: /\}/
|
---|
19 | },
|
---|
20 | {
|
---|
21 | begin: /[$@]/ + hljs.UNDERSCORE_IDENT_RE
|
---|
22 | }
|
---|
23 | ]
|
---|
24 | };
|
---|
25 | const DEFAULT = {
|
---|
26 | endsWithParent: true,
|
---|
27 | keywords: {
|
---|
28 | $pattern: '[a-z/_]+',
|
---|
29 | literal:
|
---|
30 | 'on off yes no true false none blocked debug info notice warn error crit ' +
|
---|
31 | 'select break last permanent redirect kqueue rtsig epoll poll /dev/poll'
|
---|
32 | },
|
---|
33 | relevance: 0,
|
---|
34 | illegal: '=>',
|
---|
35 | contains: [
|
---|
36 | hljs.HASH_COMMENT_MODE,
|
---|
37 | {
|
---|
38 | className: 'string',
|
---|
39 | contains: [
|
---|
40 | hljs.BACKSLASH_ESCAPE,
|
---|
41 | VAR
|
---|
42 | ],
|
---|
43 | variants: [
|
---|
44 | {
|
---|
45 | begin: /"/,
|
---|
46 | end: /"/
|
---|
47 | },
|
---|
48 | {
|
---|
49 | begin: /'/,
|
---|
50 | end: /'/
|
---|
51 | }
|
---|
52 | ]
|
---|
53 | },
|
---|
54 | // this swallows entire URLs to avoid detecting numbers within
|
---|
55 | {
|
---|
56 | begin: '([a-z]+):/',
|
---|
57 | end: '\\s',
|
---|
58 | endsWithParent: true,
|
---|
59 | excludeEnd: true,
|
---|
60 | contains: [ VAR ]
|
---|
61 | },
|
---|
62 | {
|
---|
63 | className: 'regexp',
|
---|
64 | contains: [
|
---|
65 | hljs.BACKSLASH_ESCAPE,
|
---|
66 | VAR
|
---|
67 | ],
|
---|
68 | variants: [
|
---|
69 | {
|
---|
70 | begin: "\\s\\^",
|
---|
71 | end: "\\s|\\{|;",
|
---|
72 | returnEnd: true
|
---|
73 | },
|
---|
74 | // regexp locations (~, ~*)
|
---|
75 | {
|
---|
76 | begin: "~\\*?\\s+",
|
---|
77 | end: "\\s|\\{|;",
|
---|
78 | returnEnd: true
|
---|
79 | },
|
---|
80 | // *.example.com
|
---|
81 | {
|
---|
82 | begin: "\\*(\\.[a-z\\-]+)+"
|
---|
83 | },
|
---|
84 | // sub.example.*
|
---|
85 | {
|
---|
86 | begin: "([a-z\\-]+\\.)+\\*"
|
---|
87 | }
|
---|
88 | ]
|
---|
89 | },
|
---|
90 | // IP
|
---|
91 | {
|
---|
92 | className: 'number',
|
---|
93 | begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
|
---|
94 | },
|
---|
95 | // units
|
---|
96 | {
|
---|
97 | className: 'number',
|
---|
98 | begin: '\\b\\d+[kKmMgGdshdwy]*\\b',
|
---|
99 | relevance: 0
|
---|
100 | },
|
---|
101 | VAR
|
---|
102 | ]
|
---|
103 | };
|
---|
104 |
|
---|
105 | return {
|
---|
106 | name: 'Nginx config',
|
---|
107 | aliases: [ 'nginxconf' ],
|
---|
108 | contains: [
|
---|
109 | hljs.HASH_COMMENT_MODE,
|
---|
110 | {
|
---|
111 | begin: hljs.UNDERSCORE_IDENT_RE + '\\s+\\{',
|
---|
112 | returnBegin: true,
|
---|
113 | end: /\{/,
|
---|
114 | contains: [
|
---|
115 | {
|
---|
116 | className: 'section',
|
---|
117 | begin: hljs.UNDERSCORE_IDENT_RE
|
---|
118 | }
|
---|
119 | ],
|
---|
120 | relevance: 0
|
---|
121 | },
|
---|
122 | {
|
---|
123 | begin: hljs.UNDERSCORE_IDENT_RE + '\\s',
|
---|
124 | end: ';|\\{',
|
---|
125 | returnBegin: true,
|
---|
126 | contains: [
|
---|
127 | {
|
---|
128 | className: 'attribute',
|
---|
129 | begin: hljs.UNDERSCORE_IDENT_RE,
|
---|
130 | starts: DEFAULT
|
---|
131 | }
|
---|
132 | ],
|
---|
133 | relevance: 0
|
---|
134 | }
|
---|
135 | ],
|
---|
136 | illegal: '[^\\s\\}]'
|
---|
137 | };
|
---|
138 | }
|
---|
139 |
|
---|
140 | module.exports = nginx;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.