UNPKG

1.64 kBJavaScriptView Raw
1hljs.registerLanguage("nginx",(()=>{"use strict";function e(e){
2return n("(?=",e,")")}function n(...e){return e.map((e=>{
3return(n=e)?"string"==typeof n?n:n.source:null;var n})).join("")}return a=>{
4const s={className:"variable",variants:[{begin:/\$\d+/},{begin:/\$\{\w+\}/},{
5begin:n(/[$@]/,a.UNDERSCORE_IDENT_RE)}]},i={endsWithParent:!0,keywords:{
6$pattern:/[a-z_]{2,}|\/dev\/poll/,
7literal:["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"]
8},relevance:0,illegal:"=>",contains:[a.HASH_COMMENT_MODE,{className:"string",
9contains:[a.BACKSLASH_ESCAPE,s],variants:[{begin:/"/,end:/"/},{begin:/'/,end:/'/
10}]},{begin:"([a-z]+):/",end:"\\s",endsWithParent:!0,excludeEnd:!0,contains:[s]
11},{className:"regexp",contains:[a.BACKSLASH_ESCAPE,s],variants:[{begin:"\\s\\^",
12end:"\\s|\\{|;",returnEnd:!0},{begin:"~\\*?\\s+",end:"\\s|\\{|;",returnEnd:!0},{
13begin:"\\*(\\.[a-z\\-]+)+"},{begin:"([a-z\\-]+\\.)+\\*"}]},{className:"number",
14begin:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b"},{
15className:"number",begin:"\\b\\d+[kKmMgGdshdwy]?\\b",relevance:0},s]};return{
16name:"Nginx config",aliases:["nginxconf"],contains:[a.HASH_COMMENT_MODE,{
17beginKeywords:"upstream location",end:/;|\{/,contains:i.contains,keywords:{
18section:"upstream location"}},{className:"section",
19begin:n(a.UNDERSCORE_IDENT_RE+e(/\s+\{/)),relevance:0},{
20begin:e(a.UNDERSCORE_IDENT_RE+"\\s"),end:";|\\{",contains:[{
21className:"attribute",begin:a.UNDERSCORE_IDENT_RE,starts:i}],relevance:0}],
22illegal:"[^\\s\\}\\{]"}}})());
\No newline at end of file