prism-firestore-security-rules.js 1000 B

1234567891011121314151617181920212223242526272829303132333435
  1. Prism.languages['firestore-security-rules'] = Prism.languages.extend('clike', {
  2. 'comment': /\/\/.*/,
  3. 'keyword': /\b(?:allow|function|if|match|null|return|rules_version|service)\b/,
  4. 'operator': /&&|\|\||[<>!=]=?|[-+*/%]|\b(?:in|is)\b/,
  5. });
  6. delete Prism.languages['firestore-security-rules']['class-name'];
  7. Prism.languages.insertBefore('firestore-security-rules', 'keyword', {
  8. 'path': {
  9. pattern: /(^|[\s(),])(?:\/(?:[\w\xA0-\uFFFF]+|\{[\w\xA0-\uFFFF]+(?:=\*\*)?\}|\$\([\w\xA0-\uFFFF.]+\)))+/,
  10. lookbehind: true,
  11. greedy: true,
  12. inside: {
  13. 'variable': {
  14. pattern: /\{[\w\xA0-\uFFFF]+(?:=\*\*)?\}|\$\([\w\xA0-\uFFFF.]+\)/,
  15. inside: {
  16. 'operator': /=/,
  17. 'keyword': /\*\*/,
  18. 'punctuation': /[.$(){}]/
  19. }
  20. },
  21. 'punctuation': /\//
  22. }
  23. },
  24. 'method': {
  25. // to make the pattern shorter, the actual method names are omitted
  26. pattern: /(\ballow\s+)[a-z]+(?:\s*,\s*[a-z]+)*(?=\s*[:;])/,
  27. lookbehind: true,
  28. alias: 'builtin',
  29. inside: {
  30. 'punctuation': /,/
  31. }
  32. },
  33. });