|
1 | 1 | Prism.languages.python = {
|
2 |
| - 'triple-quoted-string': { |
3 |
| - pattern: /"""[\s\S]+?"""|'''[\s\S]+?'''/, |
4 |
| - alias: 'string' |
5 |
| - }, |
6 | 2 | 'comment': {
|
7 | 3 | pattern: /(^|[^\\])#.*/,
|
8 | 4 | lookbehind: true
|
9 | 5 | },
|
| 6 | + 'triple-quoted-string': { |
| 7 | + pattern: /("""|''')[\s\S]+?\1/, |
| 8 | + greedy: true, |
| 9 | + alias: 'string' |
| 10 | + }, |
10 | 11 | 'string': {
|
11 |
| - pattern: /("|')(?:\\\\|\\?[^\\\r\n])*?\1/, |
| 12 | + pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/, |
12 | 13 | greedy: true
|
13 | 14 | },
|
14 | 15 | 'function': {
|
15 |
| - pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\s*\()/g, |
| 16 | + pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g, |
16 | 17 | lookbehind: true
|
17 | 18 | },
|
18 | 19 | 'class-name': {
|
19 |
| - pattern: /(\bclass\s+)[a-z0-9_]+/i, |
| 20 | + pattern: /(\bclass\s+)\w+/i, |
20 | 21 | lookbehind: true
|
21 | 22 | },
|
22 | 23 | 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/,
|
23 |
| - '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/, |
| 24 | + '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/, |
24 | 25 | 'boolean': /\b(?:True|False|None)\b/,
|
25 | 26 | 'number': /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
|
26 | 27 | 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
|
|
0 commit comments