[d24f17c] | 1 | Prism.languages.python = {
|
---|
| 2 | 'comment': {
|
---|
| 3 | pattern: /(^|[^\\])#.*/,
|
---|
| 4 | lookbehind: true,
|
---|
| 5 | greedy: true
|
---|
| 6 | },
|
---|
| 7 | 'string-interpolation': {
|
---|
| 8 | pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
---|
| 9 | greedy: true,
|
---|
| 10 | inside: {
|
---|
| 11 | 'interpolation': {
|
---|
| 12 | // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
---|
| 13 | pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
---|
| 14 | lookbehind: true,
|
---|
| 15 | inside: {
|
---|
| 16 | 'format-spec': {
|
---|
| 17 | pattern: /(:)[^:(){}]+(?=\}$)/,
|
---|
| 18 | lookbehind: true
|
---|
| 19 | },
|
---|
| 20 | 'conversion-option': {
|
---|
| 21 | pattern: //,
|
---|
| 22 | alias: 'punctuation'
|
---|
| 23 | },
|
---|
| 24 | rest: null
|
---|
| 25 | }
|
---|
| 26 | },
|
---|
| 27 | 'string': /[\s\S]+/
|
---|
| 28 | }
|
---|
| 29 | },
|
---|
| 30 | 'triple-quoted-string': {
|
---|
| 31 | pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
---|
| 32 | greedy: true,
|
---|
| 33 | alias: 'string'
|
---|
| 34 | },
|
---|
| 35 | 'string': {
|
---|
| 36 | pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
---|
| 37 | greedy: true
|
---|
| 38 | },
|
---|
| 39 | 'function': {
|
---|
| 40 | pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
---|
| 41 | lookbehind: true
|
---|
| 42 | },
|
---|
| 43 | 'class-name': {
|
---|
| 44 | pattern: /(\bclass\s+)\w+/i,
|
---|
| 45 | lookbehind: true
|
---|
| 46 | },
|
---|
| 47 | 'decorator': {
|
---|
| 48 | pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
---|
| 49 | lookbehind: true,
|
---|
| 50 | alias: ['annotation', 'punctuation'],
|
---|
| 51 | inside: {
|
---|
| 52 | 'punctuation': /\./
|
---|
| 53 | }
|
---|
| 54 | },
|
---|
| 55 | '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/,
|
---|
| 56 | '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/,
|
---|
| 57 | 'boolean': /\b(?:False|None|True)\b/,
|
---|
| 58 | '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,
|
---|
| 59 | 'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
---|
| 60 | 'punctuation': /[{}[\];(),.:]/
|
---|
| 61 | };
|
---|
| 62 |
|
---|
| 63 | Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
|
---|
| 64 |
|
---|
| 65 | Prism.languages.py = Prism.languages.python;
|
---|