/samples/scalate-sample-sitegen/src/highlight/languages/javascript.js

http://github.com/scalate/scalate · JavaScript · 50 lines · 46 code · 1 blank · 3 comment · 0 complexity · eed9d469f380aa9b7bd80d497cbba452 MD5 · raw file

  1. /*
  2. Language: Javascript
  3. */
  4. hljs.LANGUAGES.javascript = {
  5. defaultMode: {
  6. lexems: [hljs.UNDERSCORE_IDENT_RE],
  7. contains: ['string', 'comment', 'number', 'regexp_container', 'function'],
  8. keywords: {
  9. 'keyword': {'in': 1, 'if': 1, 'for': 1, 'while': 1, 'finally': 1, 'var': 1, 'new': 1, 'function': 1, 'do': 1, 'return': 1, 'void': 1, 'else': 1, 'break': 1, 'catch': 1, 'instanceof': 1, 'with': 1, 'throw': 1, 'case': 1, 'default': 1, 'try': 1, 'this': 1, 'switch': 1, 'continue': 1, 'typeof': 1, 'delete': 1},
  10. 'literal': {'true': 1, 'false': 1, 'null': 1}
  11. }
  12. },
  13. modes: [
  14. hljs.C_LINE_COMMENT_MODE,
  15. hljs.C_BLOCK_COMMENT_MODE,
  16. hljs.C_NUMBER_MODE,
  17. hljs.APOS_STRING_MODE,
  18. hljs.QUOTE_STRING_MODE,
  19. hljs.BACKSLASH_ESCAPE,
  20. {
  21. className: 'regexp_container',
  22. begin: '(' + hljs.RE_STARTERS_RE + '|case|return|throw)\\s*', end: '^', noMarkup: true,
  23. lexems: [hljs.IDENT_RE],
  24. keywords: {'return': 1, 'throw': 1, 'case': 1},
  25. contains: ['comment', 'regexp'],
  26. relevance: 0
  27. },
  28. {
  29. className: 'regexp',
  30. begin: '/.*?[^\\\\/]/[gim]*', end: '^'
  31. },
  32. {
  33. className: 'function',
  34. begin: '\\bfunction\\b', end: '{',
  35. lexems: [hljs.UNDERSCORE_IDENT_RE],
  36. keywords: {'function': 1},
  37. contains: ['title', 'params']
  38. },
  39. {
  40. className: 'title',
  41. begin: '[A-Za-z$_][0-9A-Za-z$_]*', end: '^'
  42. },
  43. {
  44. className: 'params',
  45. begin: '\\(', end: '\\)',
  46. contains: ['string', 'comment']
  47. }
  48. ]
  49. };