Merge pull request #850 from fperez/codemirror

Update codemirror to 2.15 and make the code internally more version-agnostic.

Added our own README file with information about what changes we carry to upstream CodeMirror and what version we currently use.
This commit is contained in:
Fernando Perez 2011-10-14 13:30:55 -07:00
commit df43150509
2 changed files with 48 additions and 43 deletions

View File

@ -1,11 +1,15 @@
CodeMirror.defineMode("python", function(conf) {
CodeMirror.defineMode("python", function(conf, parserConf) {
var ERRORCLASS = 'error';
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
}
// IPython-specific changes: add '?' as recognized character.
//var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\\?]");
// End IPython changes.
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
var doubleOperators = new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
var doubleDelimiters = new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
@ -29,7 +33,7 @@ CodeMirror.defineMode("python", function(conf) {
'open', 'range', 'zip'],
'keywords': ['nonlocal']};
if (!!conf.mode.version && parseInt(conf.mode.version, 10) === 3) {
if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {
commonkeywords = commonkeywords.concat(py3.keywords);
commontypes = commontypes.concat(py3.types);
var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
@ -147,10 +151,9 @@ CodeMirror.defineMode("python", function(conf) {
}
function tokenStringFactory(delimiter) {
while ('rub'.indexOf(delimiter[0].toLowerCase()) >= 0) {
while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
delimiter = delimiter.substr(1);
}
var delim_re = new RegExp(delimiter);
var singleline = delimiter.length == 1;
var OUTCLASS = 'string';
@ -162,7 +165,7 @@ CodeMirror.defineMode("python", function(conf) {
if (singleline && stream.eol()) {
return OUTCLASS;
}
} else if (stream.match(delim_re)) {
} else if (stream.match(delimiter)) {
state.tokenize = tokenBase;
return OUTCLASS;
} else {
@ -170,8 +173,8 @@ CodeMirror.defineMode("python", function(conf) {
}
}
if (singleline) {
if (conf.mode.singleLineStringErrors) {
OUTCLASS = ERRORCLASS
if (parserConf.singleLineStringErrors) {
return ERRORCLASS;
} else {
state.tokenize = tokenBase;
}

View File

@ -21,10 +21,11 @@
}
</script>
<link rel="stylesheet" href="static/codemirror-2.12/lib/codemirror.css">
<link rel="stylesheet" href="static/codemirror-2.12/mode/rst/rst.css">
<link rel="stylesheet" href="static/codemirror-2.12/theme/ipython.css">
<link rel="stylesheet" href="static/codemirror-2.12/theme/default.css">
<link rel="stylesheet" href="static/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="static/codemirror/mode/markdown/markdown.css">
<link rel="stylesheet" href="static/codemirror/mode/rst/rst.css">
<link rel="stylesheet" href="static/codemirror/theme/ipython.css">
<link rel="stylesheet" href="static/codemirror/theme/default.css">
<link rel="stylesheet" href="static/prettify/prettify.css"/>
@ -208,13 +209,14 @@
<script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script>
<script src="static/jquery/js/jquery.autogrow.js" type="text/javascript" charset="utf-8"></script>
<script src="static/codemirror-2.12/lib/codemirror.js" charset="utf-8"></script>
<script src="static/codemirror-2.12/mode/python/python.js" charset="utf-8"></script>
<script src="static/codemirror-2.12/mode/htmlmixed/htmlmixed.js" charset="utf-8"></script>
<script src="static/codemirror-2.12/mode/xml/xml.js" charset="utf-8"></script>
<script src="static/codemirror-2.12/mode/javascript/javascript.js" charset="utf-8"></script>
<script src="static/codemirror-2.12/mode/css/css.js" charset="utf-8"></script>
<script src="static/codemirror-2.12/mode/rst/rst.js" charset="utf-8"></script>
<script src="static/codemirror/lib/codemirror.js" charset="utf-8"></script>
<script src="static/codemirror/mode/python/python.js" charset="utf-8"></script>
<script src="static/codemirror/mode/htmlmixed/htmlmixed.js" charset="utf-8"></script>
<script src="static/codemirror/mode/xml/xml.js" charset="utf-8"></script>
<script src="static/codemirror/mode/javascript/javascript.js" charset="utf-8"></script>
<script src="static/codemirror/mode/css/css.js" charset="utf-8"></script>
<script src="static/codemirror/mode/rst/rst.js" charset="utf-8"></script>
<script src="static/codemirror/mode/markdown/markdown.js" charset="utf-8"></script>
<script src="static/pagedown/Markdown.Converter.js" charset="utf-8"></script>