Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50654 views
1
// IPython mode is just a slightly altered Python Mode with `?` beeing a extra
2
// single operator. Here we define `ipython` mode in the require `python`
3
// callback to auto-load python mode, which is more likely not the best things
4
// to do, but at least the simple one for now.
5
6
(function(mod) {
7
if (typeof exports == "object" && typeof module == "object"){ // CommonJS
8
mod(require("codemirror/lib/codemirror"),
9
require("codemirror/mode/python/python")
10
);
11
} else if (typeof define == "function" && define.amd){ // AMD
12
define(["codemirror/lib/codemirror",
13
"codemirror/mode/python/python"], mod);
14
} else {// Plain browser env
15
mod(CodeMirror);
16
}
17
})(function(CodeMirror) {
18
"use strict";
19
20
CodeMirror.defineMode("ipython", function(conf, parserConf) {
21
var pythonConf = {};
22
for (var prop in parserConf) {
23
if (parserConf.hasOwnProperty(prop)) {
24
pythonConf[prop] = parserConf[prop];
25
}
26
}
27
pythonConf.name = 'python';
28
pythonConf.singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\\?]");
29
if (pythonConf.version === 3) {
30
pythonConf.identifiers = new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
31
} else if (pythonConf.version === 2) {
32
pythonConf.identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
33
}
34
return CodeMirror.getMode(conf, pythonConf);
35
}, 'python');
36
37
CodeMirror.defineMIME("text/x-ipython", "ipython");
38
})
39
40