diff options
Diffstat (limited to 'source/languages/prism-python.js')
| -rw-r--r-- | source/languages/prism-python.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/languages/prism-python.js b/source/languages/prism-python.js new file mode 100644 index 0000000..ecad408 --- /dev/null +++ b/source/languages/prism-python.js | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | Prism.languages.python = { | ||
| 2 | 'comment': { | ||
| 3 | pattern: /(^|[^\\])#.*/, | ||
| 4 | lookbehind: true | ||
| 5 | }, | ||
| 6 | 'triple-quoted-string': { | ||
| 7 | pattern: /("""|''')[\s\S]+?\1/, | ||
| 8 | greedy: true, | ||
| 9 | alias: 'string' | ||
| 10 | }, | ||
| 11 | 'string': { | ||
| 12 | pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/, | ||
| 13 | greedy: true | ||
| 14 | }, | ||
| 15 | 'function': { | ||
| 16 | pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g, | ||
| 17 | lookbehind: true | ||
| 18 | }, | ||
| 19 | 'class-name': { | ||
| 20 | pattern: /(\bclass\s+)\w+/i, | ||
| 21 | lookbehind: true | ||
| 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/, | ||
| 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/, | ||
| 25 | 'boolean': /\b(?:True|False|None)\b/, | ||
| 26 | 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i, | ||
| 27 | 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/, | ||
| 28 | 'punctuation': /[{}[\];(),.:]/ | ||
| 29 | }; | ||
