prism-json5.js 530 B

1234567891011121314151617181920212223
  1. (function (Prism) {
  2. var string = /("|')(?:\\(?:\r\n?|\n|.)|(?!\1)[^\\\r\n])*\1/;
  3. Prism.languages.json5 = Prism.languages.extend('json', {
  4. 'property': [
  5. {
  6. pattern: RegExp(string.source + '(?=\\s*:)'),
  7. greedy: true
  8. },
  9. {
  10. pattern: /(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/,
  11. alias: 'unquoted'
  12. }
  13. ],
  14. 'string': {
  15. pattern: string,
  16. greedy: true
  17. },
  18. 'number': /[+-]?\b(?:NaN|Infinity|0x[a-fA-F\d]+)\b|[+-]?(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[eE][+-]?\d+\b)?/
  19. });
  20. }(Prism));