prismjs_components_prism-python.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // node_modules/prismjs/components/prism-python.js
  2. Prism.languages.python = {
  3. "comment": {
  4. pattern: /(^|[^\\])#.*/,
  5. lookbehind: true,
  6. greedy: true
  7. },
  8. "string-interpolation": {
  9. pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
  10. greedy: true,
  11. inside: {
  12. "interpolation": {
  13. // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
  14. pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
  15. lookbehind: true,
  16. inside: {
  17. "format-spec": {
  18. pattern: /(:)[^:(){}]+(?=\}$)/,
  19. lookbehind: true
  20. },
  21. "conversion-option": {
  22. pattern: /![sra](?=[:}]$)/,
  23. alias: "punctuation"
  24. },
  25. rest: null
  26. }
  27. },
  28. "string": /[\s\S]+/
  29. }
  30. },
  31. "triple-quoted-string": {
  32. pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
  33. greedy: true,
  34. alias: "string"
  35. },
  36. "string": {
  37. pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
  38. greedy: true
  39. },
  40. "function": {
  41. pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
  42. lookbehind: true
  43. },
  44. "class-name": {
  45. pattern: /(\bclass\s+)\w+/i,
  46. lookbehind: true
  47. },
  48. "decorator": {
  49. pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
  50. lookbehind: true,
  51. alias: ["annotation", "punctuation"],
  52. inside: {
  53. "punctuation": /\./
  54. }
  55. },
  56. "keyword": /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
  57. "builtin": /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
  58. "boolean": /\b(?:False|None|True)\b/,
  59. "number": /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
  60. "operator": /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
  61. "punctuation": /[{}[\];(),.:]/
  62. };
  63. Prism.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism.languages.python;
  64. Prism.languages.py = Prism.languages.python;
  65. //# sourceMappingURL=prismjs_components_prism-python.js.map