##// END OF EJS Templates
enable cython highlight in notebook
Matthias BUSSONNIER -
Show More
@@ -1,79 +1,80
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2012 The IPython Development Team
2 // Copyright (C) 2012 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // Notebook
9 // Notebook
10 //============================================================================
10 //============================================================================
11
11
12 /**
12 /**
13 * @module IPython
13 * @module IPython
14 * @namespace IPython
14 * @namespace IPython
15 **/
15 **/
16
16
17 var IPython = (function (IPython) {
17 var IPython = (function (IPython) {
18 "use strict";
18 "use strict";
19 /**
19 /**
20 * A place where some stuff can be confugured.
20 * A place where some stuff can be confugured.
21 *
21 *
22 * @class config
22 * @class config
23 * @static
23 * @static
24 *
24 *
25 **/
25 **/
26 var default_config = {
26 var default_config = {
27 /**
27 /**
28 * Dictionary of object to autodetect highlight mode for code cell.
28 * Dictionary of object to autodetect highlight mode for code cell.
29 * Item of the dictionnary should take the form :
29 * Item of the dictionnary should take the form :
30 *
30 *
31 * key : {'reg':[list_of_regexp]}
31 * key : {'reg':[list_of_regexp]}
32 *
32 *
33 * where `key` will be the code mirror mode name
33 * where `key` will be the code mirror mode name
34 * and `list_of_regexp` should be a list of regext that should match
34 * and `list_of_regexp` should be a list of regext that should match
35 * the first line of the cell to trigger this mode.
35 * the first line of the cell to trigger this mode.
36 *
36 *
37 * if `key` is prefixed by the `magic_` prefix the codemirror `mode`
37 * if `key` is prefixed by the `magic_` prefix the codemirror `mode`
38 * will be applied only at the end of the first line
38 * will be applied only at the end of the first line
39 *
39 *
40 * @attribute cell_magic_highlight
40 * @attribute cell_magic_highlight
41 * @example
41 * @example
42 * This would trigger javascript mode
42 * This would trigger javascript mode
43 * from the second line if first line start with `%%javascript` or `%%jsmagic`
43 * from the second line if first line start with `%%javascript` or `%%jsmagic`
44 *
44 *
45 * cell_magic_highlight['magic_javascript'] = {'reg':[/^%%javascript/,/^%%jsmagic/]}
45 * cell_magic_highlight['magic_javascript'] = {'reg':[/^%%javascript/,/^%%jsmagic/]}
46 * @example
46 * @example
47 * This would trigger javascript mode
47 * This would trigger javascript mode
48 * from the second line if first line start with `var`
48 * from the second line if first line start with `var`
49 *
49 *
50 * cell_magic_highlight['javascript'] = {'reg':[/^var/]}
50 * cell_magic_highlight['javascript'] = {'reg':[/^var/]}
51 */
51 */
52 cell_magic_highlight : {
52 cell_magic_highlight : {
53 'magic_javascript':{'reg':[/^%%javascript/]}
53 'magic_javascript' :{'reg':[/^%%javascript/]}
54 ,'magic_perl' :{'reg':[/^%%perl/]}
54 ,'magic_perl' :{'reg':[/^%%perl/]}
55 ,'magic_ruby' :{'reg':[/^%%ruby/]}
55 ,'magic_ruby' :{'reg':[/^%%ruby/]}
56 ,'magic_python' :{'reg':[/^%%python3?/]}
56 ,'magic_python' :{'reg':[/^%%python3?/]}
57 ,'magic_shell' :{'reg':[/^%%bash/]}
57 ,'magic_shell' :{'reg':[/^%%bash/]}
58 ,'magic_r' :{'reg':[/^%%R/]}
58 ,'magic_r' :{'reg':[/^%%R/]}
59 ,'magic_text/x-cython' :{'reg':[/^%%cython/]}
59 },
60 },
60
61
61 /**
62 /**
62 * same as `cell_magic_highlight` but for raw cells
63 * same as `cell_magic_highlight` but for raw cells
63 * @attribute raw_cell_highlight
64 * @attribute raw_cell_highlight
64 */
65 */
65 raw_cell_highlight : {
66 raw_cell_highlight : {
66 'diff' :{'reg':[/^diff/]}
67 'diff' :{'reg':[/^diff/]}
67 },
68 },
68
69
69 tooltip_on_tab : true,
70 tooltip_on_tab : true,
70 };
71 };
71
72
72 // use the same method to merge user configuration
73 // use the same method to merge user configuration
73 IPython.config = {};
74 IPython.config = {};
74 $.extend(IPython.config, default_config);
75 $.extend(IPython.config, default_config);
75
76
76 return IPython;
77 return IPython;
77
78
78 }(IPython));
79 }(IPython));
79
80
General Comments 0
You need to be logged in to leave comments. Login now