nginx.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. Language: Nginx
  3. Author: Peter Leonov <[email protected]>
  4. Contributors: Ivan Sagalaev <[email protected]>
  5. Category: common, config
  6. */
  7. function(hljs) {
  8. var VAR = {
  9. className: 'variable',
  10. variants: [
  11. {begin: /\$\d+/},
  12. {begin: /\$\{/, end: /}/},
  13. {begin: '[\\$\\@]' + hljs.UNDERSCORE_IDENT_RE}
  14. ]
  15. };
  16. var DEFAULT = {
  17. endsWithParent: true,
  18. lexemes: '[a-z/_]+',
  19. keywords: {
  20. literal:
  21. 'on off yes no true false none blocked debug info notice warn error crit ' +
  22. 'select break last permanent redirect kqueue rtsig epoll poll /dev/poll'
  23. },
  24. relevance: 0,
  25. illegal: '=>',
  26. contains: [
  27. hljs.HASH_COMMENT_MODE,
  28. {
  29. className: 'string',
  30. contains: [hljs.BACKSLASH_ESCAPE, VAR],
  31. variants: [
  32. {begin: /"/, end: /"/},
  33. {begin: /'/, end: /'/}
  34. ]
  35. },
  36. // this swallows entire URLs to avoid detecting numbers within
  37. {
  38. begin: '([a-z]+):/', end: '\\s', endsWithParent: true, excludeEnd: true,
  39. contains: [VAR]
  40. },
  41. {
  42. className: 'regexp',
  43. contains: [hljs.BACKSLASH_ESCAPE, VAR],
  44. variants: [
  45. {begin: "\\s\\^", end: "\\s|{|;", returnEnd: true},
  46. // regexp locations (~, ~*)
  47. {begin: "~\\*?\\s+", end: "\\s|{|;", returnEnd: true},
  48. // *.example.com
  49. {begin: "\\*(\\.[a-z\\-]+)+"},
  50. // sub.example.*
  51. {begin: "([a-z\\-]+\\.)+\\*"}
  52. ]
  53. },
  54. // IP
  55. {
  56. className: 'number',
  57. begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
  58. },
  59. // units
  60. {
  61. className: 'number',
  62. begin: '\\b\\d+[kKmMgGdshdwy]*\\b',
  63. relevance: 0
  64. },
  65. VAR
  66. ]
  67. };
  68. return {
  69. aliases: ['nginxconf'],
  70. contains: [
  71. hljs.HASH_COMMENT_MODE,
  72. {
  73. begin: hljs.UNDERSCORE_IDENT_RE + '\\s+{', returnBegin: true,
  74. end: '{',
  75. contains: [
  76. {
  77. className: 'section',
  78. begin: hljs.UNDERSCORE_IDENT_RE
  79. }
  80. ],
  81. relevance: 0
  82. },
  83. {
  84. begin: hljs.UNDERSCORE_IDENT_RE + '\\s', end: ';|{', returnBegin: true,
  85. contains: [
  86. {
  87. className: 'attribute',
  88. begin: hljs.UNDERSCORE_IDENT_RE,
  89. starts: DEFAULT
  90. }
  91. ],
  92. relevance: 0
  93. }
  94. ],
  95. illegal: '[^\\s\\}]'
  96. };
  97. }