1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/highlight.js/lib/languages/nginx.js

141 lines
2.9 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
/*
Language: Nginx config
Author: Peter Leonov <gojpeg@yandex.ru>
Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
Category: common, config
Website: https://www.nginx.com
*/
function nginx(hljs) {
const VAR = {
2023-12-18 13:12:25 +08:00
className: 'variable',
variants: [
2024-01-16 21:26:16 +08:00
{
begin: /\$\d+/
},
{
begin: /\$\{/,
end: /\}/
},
{
begin: /[$@]/ + hljs.UNDERSCORE_IDENT_RE
}
2023-12-18 13:12:25 +08:00
]
};
2024-01-16 21:26:16 +08:00
const DEFAULT = {
2023-12-18 13:12:25 +08:00
endsWithParent: true,
keywords: {
2024-01-16 21:26:16 +08:00
$pattern: '[a-z/_]+',
2023-12-18 13:12:25 +08:00
literal:
'on off yes no true false none blocked debug info notice warn error crit ' +
'select break last permanent redirect kqueue rtsig epoll poll /dev/poll'
},
relevance: 0,
illegal: '=>',
contains: [
hljs.HASH_COMMENT_MODE,
{
className: 'string',
2024-01-16 21:26:16 +08:00
contains: [
hljs.BACKSLASH_ESCAPE,
VAR
],
2023-12-18 13:12:25 +08:00
variants: [
2024-01-16 21:26:16 +08:00
{
begin: /"/,
end: /"/
},
{
begin: /'/,
end: /'/
}
2023-12-18 13:12:25 +08:00
]
},
// this swallows entire URLs to avoid detecting numbers within
{
2024-01-16 21:26:16 +08:00
begin: '([a-z]+):/',
end: '\\s',
endsWithParent: true,
excludeEnd: true,
contains: [ VAR ]
2023-12-18 13:12:25 +08:00
},
{
className: 'regexp',
2024-01-16 21:26:16 +08:00
contains: [
hljs.BACKSLASH_ESCAPE,
VAR
],
2023-12-18 13:12:25 +08:00
variants: [
2024-01-16 21:26:16 +08:00
{
begin: "\\s\\^",
end: "\\s|\\{|;",
returnEnd: true
},
2023-12-18 13:12:25 +08:00
// regexp locations (~, ~*)
2024-01-16 21:26:16 +08:00
{
begin: "~\\*?\\s+",
end: "\\s|\\{|;",
returnEnd: true
},
2023-12-18 13:12:25 +08:00
// *.example.com
2024-01-16 21:26:16 +08:00
{
begin: "\\*(\\.[a-z\\-]+)+"
},
2023-12-18 13:12:25 +08:00
// sub.example.*
2024-01-16 21:26:16 +08:00
{
begin: "([a-z\\-]+\\.)+\\*"
}
2023-12-18 13:12:25 +08:00
]
},
// IP
{
className: 'number',
begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
},
// units
{
className: 'number',
begin: '\\b\\d+[kKmMgGdshdwy]*\\b',
relevance: 0
},
VAR
]
};
return {
2024-01-16 21:26:16 +08:00
name: 'Nginx config',
aliases: [ 'nginxconf' ],
2023-12-18 13:12:25 +08:00
contains: [
hljs.HASH_COMMENT_MODE,
{
2024-01-16 21:26:16 +08:00
begin: hljs.UNDERSCORE_IDENT_RE + '\\s+\\{',
returnBegin: true,
end: /\{/,
2023-12-18 13:12:25 +08:00
contains: [
{
className: 'section',
begin: hljs.UNDERSCORE_IDENT_RE
}
],
relevance: 0
},
{
2024-01-16 21:26:16 +08:00
begin: hljs.UNDERSCORE_IDENT_RE + '\\s',
end: ';|\\{',
returnBegin: true,
2023-12-18 13:12:25 +08:00
contains: [
{
className: 'attribute',
begin: hljs.UNDERSCORE_IDENT_RE,
starts: DEFAULT
}
],
relevance: 0
}
],
illegal: '[^\\s\\}]'
};
2024-01-16 21:26:16 +08:00
}
module.exports = nginx;