PageRenderTime 5ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/samples/scalate-presentation/src/highlight/languages/python.js

http://github.com/scalate/scalate
JavaScript | 75 lines | 71 code | 1 blank | 3 comment | 0 complexity | 42c4efc362c1fa73323e191433e7dcb2 MD5 | raw file
  1. /*
  2. Language: Python
  3. */
  4. hljs.LANGUAGES.python = {
  5. defaultMode: {
  6. lexems: [hljs.UNDERSCORE_IDENT_RE],
  7. illegal: '(</|->)',
  8. contains: ['comment', 'string', 'function', 'class', 'number', 'decorator'],
  9. keywords: {
  10. 'keyword': {'and': 1, 'elif': 1, 'is': 1, 'global': 1, 'as': 1, 'in': 1, 'if': 1, 'from': 1, 'raise': 1, 'for': 1, 'except': 1, 'finally': 1, 'print': 1, 'import': 1, 'pass': 1, 'return': 1, 'exec': 1, 'else': 1, 'break': 1, 'not': 1, 'with': 1, 'class': 1, 'assert': 1, 'yield': 1, 'try': 1, 'while': 1, 'continue': 1, 'del': 1, 'or': 1, 'def': 1, 'lambda': 1, 'nonlocal': 10},
  11. 'built_in': {'None': 1, 'True': 1, 'False': 1, 'Ellipsis': 1, 'NotImplemented': 1}
  12. }
  13. },
  14. modes: [
  15. {
  16. className: 'function',
  17. lexems: [hljs.UNDERSCORE_IDENT_RE],
  18. begin: '\\bdef ', end: ':',
  19. illegal: '$',
  20. keywords: {'def': 1},
  21. contains: ['title', 'params'],
  22. relevance: 10
  23. },
  24. {
  25. className: 'class',
  26. lexems: [hljs.UNDERSCORE_IDENT_RE],
  27. begin: '\\bclass ', end: ':',
  28. illegal: '[${]',
  29. keywords: {'class': 1},
  30. contains: ['title', 'params'],
  31. relevance: 10
  32. },
  33. {
  34. className: 'title',
  35. begin: hljs.UNDERSCORE_IDENT_RE, end: '^'
  36. },
  37. {
  38. className: 'params',
  39. begin: '\\(', end: '\\)',
  40. contains: ['string']
  41. },
  42. hljs.HASH_COMMENT_MODE,
  43. hljs.C_NUMBER_MODE,
  44. {
  45. className: 'string',
  46. begin: 'u?r?\'\'\'', end: '\'\'\'',
  47. relevance: 10
  48. },
  49. {
  50. className: 'string',
  51. begin: 'u?r?"""', end: '"""',
  52. relevance: 10
  53. },
  54. hljs.APOS_STRING_MODE,
  55. hljs.QUOTE_STRING_MODE,
  56. hljs.BACKSLASH_ESCAPE,
  57. {
  58. className: 'string',
  59. begin: '(u|r|ur)\'', end: '\'',
  60. contains: ['escape'],
  61. relevance: 10
  62. },
  63. {
  64. className: 'string',
  65. begin: '(u|r|ur)"', end: '"',
  66. contains: ['escape'],
  67. relevance: 10
  68. },
  69. {
  70. className: 'decorator',
  71. begin: '@', end: '$'
  72. }
  73. ]
  74. };