2021-03-10 11:35:00 -05:00
|
|
|
hljs.registerLanguage("python",(()=>{"use strict";return e=>{const n={
|
2021-03-18 18:21:23 -04:00
|
|
|
keyword:["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","","from","global","if","import","in","is","lambda","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],
|
2021-03-10 11:35:00 -05:00
|
|
|
built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],
|
2021-03-18 18:21:23 -04:00
|
|
|
literal:["__debug__","Ellipsis","False","None","NotImplemented","True"]},a={
|
|
|
|
className:"meta",begin:/^(>>>|\.\.\.) /},s={className:"subst",begin:/\{/,
|
|
|
|
end:/\}/,keywords:n,illegal:/#/},i={begin:/\{\{/,relevance:0},r={
|
2021-03-10 11:35:00 -05:00
|
|
|
className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{
|
|
|
|
begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,
|
|
|
|
contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{
|
|
|
|
begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,
|
|
|
|
contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{
|
|
|
|
begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,
|
2021-03-18 18:21:23 -04:00
|
|
|
contains:[e.BACKSLASH_ESCAPE,a,i,s]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,
|
|
|
|
end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,i,s]},{begin:/([uU]|[rR])'/,end:/'/,
|
2021-03-10 11:35:00 -05:00
|
|
|
relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{
|
|
|
|
begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,
|
|
|
|
end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,
|
2021-03-18 18:21:23 -04:00
|
|
|
contains:[e.BACKSLASH_ESCAPE,i,s]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,
|
|
|
|
contains:[e.BACKSLASH_ESCAPE,i,s]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]
|
2021-03-10 11:35:00 -05:00
|
|
|
},t="[0-9](_?[0-9])*",l=`(\\b(${t}))?\\.(${t})|\\b(${t})\\.`,b={
|
|
|
|
className:"number",relevance:0,variants:[{
|
|
|
|
begin:`(\\b(${t})|(${l}))[eE][+-]?(${t})[jJ]?\\b`},{begin:`(${l})[jJ]?`},{
|
|
|
|
begin:"\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?\\b"},{
|
|
|
|
begin:"\\b0[bB](_?[01])+[lL]?\\b"},{begin:"\\b0[oO](_?[0-7])+[lL]?\\b"},{
|
|
|
|
begin:"\\b0[xX](_?[0-9a-fA-F])+[lL]?\\b"},{begin:`\\b(${t})[jJ]\\b`}]},o={
|
2021-03-18 18:21:23 -04:00
|
|
|
className:"params",variants:[{begin:/\(\s*\)/,skip:!0,className:null},{
|
|
|
|
begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:n,
|
|
|
|
contains:["self",a,b,r,e.HASH_COMMENT_MODE]}]};return s.contains=[r,b,a],{
|
|
|
|
name:"Python",aliases:["py","gyp","ipython"],keywords:n,
|
|
|
|
illegal:/(<\/|->|\?)|=>/,contains:[a,b,{begin:/\bself\b/},{beginKeywords:"if",
|
|
|
|
relevance:0},r,e.HASH_COMMENT_MODE,{variants:[{className:"function",
|
|
|
|
beginKeywords:"def"},{className:"class",beginKeywords:"class"}],end:/:/,
|
|
|
|
illegal:/[${=;\n,]/,contains:[e.UNDERSCORE_TITLE_MODE,o,{begin:/->/,
|
|
|
|
endsWithParent:!0,keywords:"None"}]},{className:"meta",begin:/^[\t ]*@/,
|
|
|
|
end:/(?=#)|$/,contains:[b,o,r]},{begin:/\b(print|exec)\(/}]}}})());
|