Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/assets/rainbow/python.js
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/**6* Python patterns7*8* @author Craig Campbell9* @version 1.0.610*/11Rainbow.extend('python', [12/**13* don't highlight self as a keyword14*/15{16'name': 'variable.self',17'pattern': /self/g18},19{20'name': 'constant.language',21'pattern': /None|True|False/g22},23{24'name': 'support.object',25'pattern': /object/g26},2728/**29* built in python functions30*31* this entire list is 580 bytes minified / 379 bytes gzipped32*33* @see http://docs.python.org/library/functions.html34*35* @todo strip some out or consolidate the regexes with matching patterns?36*/37{38'name': 'support.function.python',39'pattern': /\b(bs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|bin|file|iter|property|tuple|bool|filter|len|range|type|bytearray|float|list|raw_input|unichr|callable|format|locals|reduce|unicode|chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|__import__|complex|hash|min|set|apply|delattr|help|next|setattr|buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern)(?=\()/g40},41{42'matches': {431: 'keyword'44},45'pattern': /\b(pass|lambda|with|is|not|in|from|elif)(?=\(|\b)/g46},47{48'matches': {491: 'storage.class',502: 'entity.name.class',513: 'entity.other.inherited-class'52},53'pattern': /(class)\s+(\w+)\((\w+?)\)/g54},55{56'matches': {571: 'storage.function',582: 'support.magic'59},60'pattern': /(def)\s+(__\w+)(?=\()/g61},62{63'name': 'support.magic',64'pattern': /__(name)__/g65},66{67'matches': {681: 'keyword.control',692: 'support.exception.type'70},71'pattern': /(except) (\w+):/g72},73{74'matches': {751: 'storage.function',762: 'entity.name.function'77},78'pattern': /(def)\s+(\w+)(?=\()/g79},80{81'name': 'entity.name.function.decorator',82'pattern': /@(\w+)/g83},84{85'name': 'comment.docstring',86'pattern': /('{3}|"{3})[\s\S]*?\1/gm87}88]);899091