1
|
{"version":3,"file":"highlight/python.js?v=a9fbdf5051a47e429f77","mappings":"8GAoBA,SAASA,EAAUC,GACjB,OAOF,YAAmBC,GAEjB,OADeA,EAAKC,KAAKC,GApB3B,SAAgBH,GACd,OAAKA,EACa,iBAAPA,EAAwBA,EAE5BA,EAAGI,OAHM,KAmBeA,CAAOD,KAAIE,KAAK,IARxCC,CAAO,MAAON,EAAI,KAwa3BO,EAAOC,QArZP,SAAgBC,GACd,MAuIMC,EAAW,CACfC,SAAU,sBACVC,QAzIqB,CACrB,MACA,KACA,SACA,QACA,QACA,QACA,QACA,WACA,MACA,MACA,OACA,OACA,SACA,UACA,MACA,OACA,SACA,KACA,SACA,KACA,KACA,SACA,cACA,MACA,KACA,OACA,QACA,SACA,MACA,QACA,OACA,SA0GAC,SAvGgB,CAChB,aACA,MACA,MACA,MACA,QACA,MACA,OACA,aACA,YACA,QACA,WACA,MACA,cACA,UACA,UACA,UACA,OACA,MACA,SACA,YACA,OACA,OACA,SACA,QACA,SACA,YACA,UACA,UACA,UACA,OACA,OACA,MACA,KACA,QACA,MACA,aACA,aACA,OACA,MACA,OACA,SACA,MACA,MACA,aACA,MACA,OACA,SACA,MACA,OACA,MACA,MACA,QACA,WACA,QACA,OACA,WACA,QACA,MACA,UACA,QACA,SACA,eACA,MACA,MACA,QACA,QACA,OACA,OACA,OAmCAC,QAhCe,CACf,YACA,WACA,QACA,OACA,iBACA,QA2BAC,KArBY,CACZ,MACA,WACA,YACA,OACA,OACA,UACA,UACA,WACA,WACA,MACA,QACA,OACA,UAWIC,EAAS,CACbC,UAAW,OACXC,MAAO,kBAGHC,EAAQ,CACZF,UAAW,QACXC,MAAO,KACPE,IAAK,KACLC,SAAUX,EACVY,QAAS,KAGLC,EAAkB,CACtBL,MAAO,OACPM,UAAW,GAGPC,EAAS,CACbR,UAAW,SACXS,SAAU,CAAEjB,EAAKkB,kBACjBC,SAAU,CACR,CACEV,MAAO,yCACPE,IAAK,MACLM,SAAU,CACRjB,EAAK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AMO,SAAW,CACfD,EACAQ,EACAjB,GAGK,CACLyB,KAAM,SACNC,QAAS,CACP,KACA,MACA,WAEFrB,SAAUX,EACVY,QAAS,iBACTI,SAAU,CACRV,EACAiB,EACA,CAEEf,MAAO,YAET,CAGEyB,cAAe,KACfnB,UAAW,GAEbC,EACAS,EACAzB,EAAK+B,kBACL,CACEZ,SAAU,CACR,CACEX,UAAW,WACX0B,cAAe,OAEjB,CACE1B,UAAW,QACX0B,cAAe,UAGnBvB,IAAK,IACLE,QAAS,YACTI,SAAU,CACRjB,EAAKmC,sBACLR,EACA,CACElB,MAAO,KACPiB,gBAAgB,EAChBd,SAAUX,KAIhB,CACEO,UAAW,OACXC,MAAO,WACPE,IAAK,UACLM,SAAU,CACRO,EACAG,EACAX","sources":["webpack:///text/node_modules/highlight.js/lib/languages/python.js"],"sourcesContent":["/**\n * @param {string} value\n * @returns {RegExp}\n * */\n\n/**\n * @param {RegExp | string } re\n * @returns {string}\n */\nfunction source(re) {\n if (!re) return null;\n if (typeof re === \"string\") return re;\n\n return re.source;\n}\n\n/**\n * @param {RegExp | string } re\n * @returns {string}\n */\nfunction lookahead(re) {\n return concat('(?=', re, ')');\n}\n\n/**\n * @param {...(RegExp | string) } args\n * @returns {string}\n */\nfunction concat(...args) {\n const joined = args.map((x) => source(x)).join(\"\");\n return joined;\n}\n\n/*\nLanguage: Python\nDescription: Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.\nWebsite: https://www.python.org\nCategory: common\n*/\n\nfunction python(hljs) {\n const RESERVED_WORDS = [\n 'and',\n 'as',\n 'assert',\n 'async',\n 'await',\n 'break',\n 'class',\n 'continue',\n 'def',\n 'del',\n 'elif',\n 'else',\n 'except',\n 'finally',\n 'for',\n 'from',\n 'global',\n 'if',\n 'import',\n 'in',\n 'is',\n 'lambda',\n 'nonlocal|10',\n 'not',\n 'or',\n 'pass',\n 'raise',\n 'return',\n 'try',\n 'while',\n 'with',\n 'yield'\n ];\n\n const BUILT_INS = [\n '__import__',\n 'abs',\n 'all',\n 'any',\n 'ascii',\n 'bin',\n 'bool',\n 'breakpoint',\n 'bytearray',\n 'bytes',\n 'callable',\n 'chr',\n 'classmethod',\n 'compile',\n 'complex',\n 'delattr',\n 'dict',\n 'dir',\n 'divmod',\n 'enumerate',\n 'eval',\n 'exec',\n 'filter',\n 'float',\n 'format',\n 'frozenset',\n 'getattr',\n 'globals',\n 'hasattr',\n 'hash',\n 'help',\n 'hex',\n 'id',\n 'input',\n 'int',\n 'isinstance',\n 'issubclass',\n 'iter',\n 'len',\n 'list',\n 'locals',\n 'map',\n 'max',\n 'memoryview',\n 'min',\n 'next',\n 'object',\n 'oct',\n 'open',\n 'ord',\n 'pow',\n 'print',\n 'property',\n 'range',\n 'repr',\n 'reversed',\n 'round',\n 'set',\n 'setattr',\n 'slice',\n 'sorted',\n 'staticmethod',\n 'str',\n 'sum',\n 'super',\n 'tuple',\n 'type',\n 'vars',\n 'zip'\n ];\n\n const LITERALS = [\n '__debug__',\n 'Ellipsis',\n 'False',\n 'None',\n 'NotImplemented',\n 'True'\n ];\n\n // https://docs.python.org/3/library/typing.html\n // TODO: Could these be supplemented by a CamelCase matcher in certain\n // contexts, leaving these remaining only for relevance hinting?\n const TYPES = [\n \"Any\",\n \"Callable\",\n \"Coroutine\",\n \"Dict\",\n \"List\",\n \"Literal\",\n \"Generic\",\n \"Optional\",\n \"Sequence\",\n \"Set\",\n \"Tuple\",\n \"Type\",\n \"Union\"\n ];\n\n const KEYWORDS = {\n $pattern: /[A-Za-z]\\w+|__\\w+__/,\n keyword: RESERVED_WORDS,\n built_in: BUILT_INS,\n literal: LITERALS,\n type: TYPES\n };\n\n const PROMPT = {\n className: 'meta',\n begin: /^(>>>|\\.\\.\\.) /\n };\n\n const SUBST = {\n className: 'subst',\n begin: /\\{/,\n end: /\\}/,\n keywords: KEYWORDS,\n illegal: /#/\n };\n\n const LITERAL_BRACKET = {\n begin: /\\{\\{/,\n relevance: 0\n };\n\n const STRING = {\n className: 'string',\n contains: [ hljs.BACKSLASH_ESCAPE ],\n variants: [\n {\n begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,\n end: /'''/,\n contains: [\n hljs.BACKSLASH_ESCAPE,\n PROMPT\n ],\n relevance: 10\n },\n {\n begin: /([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?\"\"\"/,\n end: /\"\"\"/,\n contains: [\n hljs.BACKSLASH_ESCAPE,\n PROMPT\n ],\n relevance: 10\n },\n {\n begin: /([fF][rR]|[rR][fF]|[fF])'''/,\n end: /'''/,\n contains: [\n hljs.BACKSLASH_ESCAPE,\n PROMPT,\n LITERAL_BRACKET,\n SUBST\n ]\n },\n {\n begin: /([fF][rR]|[rR][fF]|[fF])\"\"\"/,\n end: /\"\"\"/,\n contains: [\n hljs.BACKSLASH_ESCAPE,\n PROMPT,\n LITERAL_BRACKET,\n SUBST\n ]\n },\n {\n begin: /([uU]|[rR])'/,\n end: /'/,\n relevance: 10\n },\n {\n begin: /([uU]|[rR])\"/,\n end: /\"/,\n relevance: 10\n },\n {\n begin: /([bB]|[bB][rR]|[rR][bB])'/,\n end: /'/\n },\n {\n begin: /([bB]|[bB][rR]|[rR][bB])\"/,\n end: /\"/\n },\n {\n begin: /([fF][rR]|[rR][fF]|[fF])'/,\n end: /'/,\n contains: [\n hljs.BACKSLASH_ESCAPE,\n LITERAL_BRACKET,\n SUBST\n ]\n },\n {\n begin: /([fF][rR]|[rR][fF]|[fF])\"/,\n end: /\"/,\n contains: [\n hljs.BACKSLASH_ESCAPE,\n LITERAL_BRACKET,\n SUBST\n ]\n },\n hljs.APOS_STRING_MODE,\n hljs.QUOTE_STRING_MODE\n ]\n };\n\n // https://docs.python.org/3.9/reference/lexical_analysis.html#numeric-literals\n const digitpart = '[0-9](_?[0-9])*';\n const pointfloat = `(\\\\b(${digitpart}))?\\\\.(${digitpart})|\\\\b(${digitpart})\\\\.`;\n const NUMBER = {\n className: 'number',\n relevance: 0,\n variants: [\n // exponentfloat, pointfloat\n // https://docs.python.org/3.9/reference/lexical_analysis.html#floating-point-literals\n // optionally imaginary\n // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals\n // Note: no leading \\b because floats can start with a decimal point\n // and we don't want to mishandle e.g. `fn(.5)`,\n // no trailing \\b for pointfloat because it can end with a decimal point\n // and we don't want to mishandle e.g. `0..hex()`; this should be safe\n // because both MUST contain a decimal point and so cannot be confused with\n // the interior part of an identifier\n {\n begin: `(\\\\b(${digitpart})|(${pointfloat}))[eE][+-]?(${digitpart})[jJ]?\\\\b`\n },\n {\n begin: `(${pointfloat})[jJ]?`\n },\n\n // decinteger, bininteger, octinteger, hexinteger\n // https://docs.python.org/3.9/reference/lexical_analysis.html#integer-literals\n // optionally \"long\" in Python 2\n // https://docs.python.org/2.7/reference/lexical_analysis.html#integer-and-long-integer-literals\n // decinteger is optionally imaginary\n // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals\n {\n begin: '\\\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?\\\\b'\n },\n {\n begin: '\\\\b0[bB](_?[01])+[lL]?\\\\b'\n },\n {\n begin: '\\\\b0[oO](_?[0-7])+[lL]?\\\\b'\n },\n {\n begin: '\\\\b0[xX](_?[0-9a-fA-F])+[lL]?\\\\b'\n },\n\n // imagnumber (digitpart-based)\n // https://docs.python.org/3.9/reference/lexical_analysis.html#imaginary-literals\n {\n begin: `\\\\b(${digitpart})[jJ]\\\\b`\n }\n ]\n };\n const COMMENT_TYPE = {\n className: \"comment\",\n begin: lookahead(/# type:/),\n end: /$/,\n keywords: KEYWORDS,\n contains: [\n { // prevent keywords from coloring `type`\n begin: /# type:/\n },\n // comment within a datatype comment includes no keywords\n {\n begin: /#/,\n end: /\\b\\B/,\n endsWithParent: true\n }\n ]\n };\n const PARAMS = {\n className: 'params',\n variants: [\n // Exclude params in functions without params\n {\n className: \"\",\n begin: /\\(\\s*\\)/,\n skip: true\n },\n {\n begin: /\\(/,\n end: /\\)/,\n excludeBegin: true,\n excludeEnd: true,\n keywords: KEYWORDS,\n contains: [\n 'self',\n PROMPT,\n NUMBER,\n STRING,\n hljs.HASH_COMMENT_MODE\n ]\n }\n ]\n };\n SUBST.contains = [\n STRING,\n NUMBER,\n PROMPT\n ];\n\n return {\n name: 'Python',\n aliases: [\n 'py',\n 'gyp',\n 'ipython'\n ],\n keywords: KEYWORDS,\n illegal: /(<\\/|->|\\?)|=>/,\n contains: [\n PROMPT,\n NUMBER,\n {\n // very common convention\n begin: /\\bself\\b/\n },\n {\n // eat \"if\" prior to string so that it won't accidentally be\n // labeled as an f-string\n beginKeywords: \"if\",\n relevance: 0\n },\n STRING,\n COMMENT_TYPE,\n hljs.HASH_COMMENT_MODE,\n {\n variants: [\n {\n className: 'function',\n beginKeywords: 'def'\n },\n {\n className: 'class',\n beginKeywords: 'class'\n }\n ],\n end: /:/,\n illegal: /[${=;\\n,]/,\n contains: [\n hljs.UNDERSCORE_TITLE_MODE,\n PARAMS,\n {\n begin: /->/,\n endsWithParent: true,\n keywords: KEYWORDS\n }\n ]\n },\n {\n className: 'meta',\n begin: /^[\\t ]*@/,\n end: /(?=#)|$/,\n contains: [\n NUMBER,\n PARAMS,\n STRING\n ]\n }\n ]\n };\n}\n\nmodule.exports = python;\n"],"names":["lookahead","re","args","map","x","source","join","concat","module","exports","hljs","KEYWORDS","$pattern","keyword","built_in","literal","type","PROMPT","className","begin","SUBST","end","keywords","illegal","LITERAL_BRACKET","relevance","STRING","contains","BACKSLASH_ESCAPE","variants","APOS_STRING_MODE","QUOTE_STRING_MODE","digitpart","pointfloat","NUMBER","COMMENT_TYPE","endsWithParent","PARAMS","skip","excludeBegin","excludeEnd","HASH_COMMENT_MODE","name","aliases","beginKeywords","UNDERSCORE_TITLE_MODE"],"sourceRoot":""}
|