MCPcopy Create free account
hub / github.com/unconed/TermKit / Brush

Function Brush

HTML/external/syntaxhighlighter_3.0.83/scripts/shBrushPython.js:22–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20 typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
21
22 function Brush()
23 {
24 // Contributed by Gheorghe Milas and Ahmad Sherif
25
26 var keywords = 'and assert break class continue def del elif else ' +
27 'except exec finally for from global if import in is ' +
28 'lambda not or pass print raise return try yield while';
29
30 var funcs = '__import__ abs all any apply basestring bin bool buffer callable ' +
31 'chr classmethod cmp coerce compile complex delattr dict dir ' +
32 'divmod enumerate eval execfile file filter float format frozenset ' +
33 'getattr globals hasattr hash help hex id input int intern ' +
34 'isinstance issubclass iter len list locals long map max min next ' +
35 'object oct open ord pow print property range raw_input reduce ' +
36 'reload repr reversed round set setattr slice sorted staticmethod ' +
37 'str sum super tuple type type unichr unicode vars xrange zip';
38
39 var special = 'None True False self cls class_';
40
41 this.regexList = [
42 { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' },
43 { regex: /^\s*@\w+/gm, css: 'decorator' },
44 { regex: /(['\"]{3})([^\1])*?\1/gm, css: 'comments' },
45 { regex: /"(?!")(?:\.|\\\"|[^\""\n])*"/gm, css: 'string' },
46 { regex: /'(?!')(?:\.|(\\\')|[^\''\n])*'/gm, css: 'string' },
47 { regex: /\+|\-|\*|\/|\%|=|==/gm, css: 'keyword' },
48 { regex: /\b\d+\.?\w*/g, css: 'value' },
49 { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' },
50 { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
51 { regex: new RegExp(this.getKeywords(special), 'gm'), css: 'color1' }
52 ];
53
54 this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
55 };
56
57 Brush.prototype = new SyntaxHighlighter.Highlighter();
58 Brush.aliases = ['py', 'python'];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected