]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/nginx.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / nginx.js
1 /*! `nginx` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Nginx config
7 Author: Peter Leonov <gojpeg@yandex.ru>
8 Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
9 Category: config, web
10 Website: https://www.nginx.com
11 */
12
13 /** @type LanguageFn */
14 function nginx(hljs) {
15 const regex = hljs.regex;
16 const VAR = {
17 className: 'variable',
18 variants: [
19 { begin: /\$\d+/ },
20 { begin: /\$\{\w+\}/ },
21 { begin: regex.concat(/[$@]/, hljs.UNDERSCORE_IDENT_RE) }
22 ]
23 };
24 const LITERALS = [
25 "on",
26 "off",
27 "yes",
28 "no",
29 "true",
30 "false",
31 "none",
32 "blocked",
33 "debug",
34 "info",
35 "notice",
36 "warn",
37 "error",
38 "crit",
39 "select",
40 "break",
41 "last",
42 "permanent",
43 "redirect",
44 "kqueue",
45 "rtsig",
46 "epoll",
47 "poll",
48 "/dev/poll"
49 ];
50 const DEFAULT = {
51 endsWithParent: true,
52 keywords: {
53 $pattern: /[a-z_]{2,}|\/dev\/poll/,
54 literal: LITERALS
55 },
56 relevance: 0,
57 illegal: '=>',
58 contains: [
59 hljs.HASH_COMMENT_MODE,
60 {
61 className: 'string',
62 contains: [
63 hljs.BACKSLASH_ESCAPE,
64 VAR
65 ],
66 variants: [
67 {
68 begin: /"/,
69 end: /"/
70 },
71 {
72 begin: /'/,
73 end: /'/
74 }
75 ]
76 },
77 // this swallows entire URLs to avoid detecting numbers within
78 {
79 begin: '([a-z]+):/',
80 end: '\\s',
81 endsWithParent: true,
82 excludeEnd: true,
83 contains: [ VAR ]
84 },
85 {
86 className: 'regexp',
87 contains: [
88 hljs.BACKSLASH_ESCAPE,
89 VAR
90 ],
91 variants: [
92 {
93 begin: "\\s\\^",
94 end: "\\s|\\{|;",
95 returnEnd: true
96 },
97 // regexp locations (~, ~*)
98 {
99 begin: "~\\*?\\s+",
100 end: "\\s|\\{|;",
101 returnEnd: true
102 },
103 // *.example.com
104 { begin: "\\*(\\.[a-z\\-]+)+" },
105 // sub.example.*
106 { begin: "([a-z\\-]+\\.)+\\*" }
107 ]
108 },
109 // IP
110 {
111 className: 'number',
112 begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
113 },
114 // units
115 {
116 className: 'number',
117 begin: '\\b\\d+[kKmMgGdshdwy]?\\b',
118 relevance: 0
119 },
120 VAR
121 ]
122 };
123
124 return {
125 name: 'Nginx config',
126 aliases: [ 'nginxconf' ],
127 contains: [
128 hljs.HASH_COMMENT_MODE,
129 {
130 beginKeywords: "upstream location",
131 end: /;|\{/,
132 contains: DEFAULT.contains,
133 keywords: { section: "upstream location" }
134 },
135 {
136 className: 'section',
137 begin: regex.concat(hljs.UNDERSCORE_IDENT_RE + regex.lookahead(/\s+\{/)),
138 relevance: 0
139 },
140 {
141 begin: regex.lookahead(hljs.UNDERSCORE_IDENT_RE + '\\s'),
142 end: ';|\\{',
143 contains: [
144 {
145 className: 'attribute',
146 begin: hljs.UNDERSCORE_IDENT_RE,
147 starts: DEFAULT
148 }
149 ],
150 relevance: 0
151 }
152 ],
153 illegal: '[^\\s\\}\\{]'
154 };
155 }
156
157 return nginx;
158
159 })();
160 ;
161 export default hljsGrammar;