prism-nginx.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. (function (Prism) {
  2. var variable = /\$(?:\w[a-z\d]*(?:_[^\x00-\x1F\s"'\\()$]*)?|\{[^}\s"'\\]+\})/i;
  3. Prism.languages.nginx = {
  4. 'comment': {
  5. pattern: /(^|[\s{};])#.*/,
  6. lookbehind: true,
  7. greedy: true
  8. },
  9. 'directive': {
  10. pattern: /(^|\s)\w(?:[^;{}"'\\\s]|\\.|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|\s+(?:#.*(?!.)|(?![#\s])))*?(?=\s*[;{])/,
  11. lookbehind: true,
  12. greedy: true,
  13. inside: {
  14. 'string': {
  15. pattern: /((?:^|[^\\])(?:\\\\)*)(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/,
  16. lookbehind: true,
  17. greedy: true,
  18. inside: {
  19. 'escape': {
  20. pattern: /\\["'\\nrt]/,
  21. alias: 'entity'
  22. },
  23. 'variable': variable
  24. }
  25. },
  26. 'comment': {
  27. pattern: /(\s)#.*/,
  28. lookbehind: true,
  29. greedy: true
  30. },
  31. 'keyword': {
  32. pattern: /^\S+/,
  33. greedy: true
  34. },
  35. // other patterns
  36. 'boolean': {
  37. pattern: /(\s)(?:off|on)(?!\S)/,
  38. lookbehind: true
  39. },
  40. 'number': {
  41. pattern: /(\s)\d+[a-z]*(?!\S)/i,
  42. lookbehind: true
  43. },
  44. 'variable': variable
  45. }
  46. },
  47. 'punctuation': /[{};]/
  48. };
  49. }(Prism));