|
41 | 41 | CodeMirror.defineMode("python", function(conf, parserConf) { |
42 | 42 | var ERRORCLASS = "error"; |
43 | 43 |
|
44 | | - var delimiters = parserConf.delimiters || parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.]/; |
| 44 | + var delimiters = parserConf.delimiters || parserConf.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.\\]/; |
45 | 45 | // (Backwards-compatiblity with old, cumbersome config system) |
46 | 46 | var operators = [parserConf.singleOperators, parserConf.doubleOperators, parserConf.doubleDelimiters, parserConf.tripleDelimiters, |
47 | 47 | parserConf.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@])/] |
|
76 | 76 |
|
77 | 77 | // tokenizers |
78 | 78 | function tokenBase(stream, state) { |
79 | | - if (stream.sol()) state.indent = stream.indentation() |
| 79 | + var sol = stream.sol() && state.lastToken != "\\" |
| 80 | + if (sol) state.indent = stream.indentation() |
80 | 81 | // Handle scope changes |
81 | | - if (stream.sol() && top(state).type == "py") { |
| 82 | + if (sol && top(state).type == "py") { |
82 | 83 | var scopeOffset = top(state).offset; |
83 | 84 | if (stream.eatSpace()) { |
84 | 85 | var lineOffset = stream.indentation(); |
|
100 | 101 | function tokenBaseInner(stream, state) { |
101 | 102 | if (stream.eatSpace()) return null; |
102 | 103 |
|
103 | | - var ch = stream.peek(); |
104 | | - |
105 | 104 | // Handle Comments |
106 | | - if (ch == "#") { |
107 | | - stream.skipToEnd(); |
108 | | - return "comment"; |
109 | | - } |
| 105 | + if (stream.match(/^#.*/)) return "comment"; |
110 | 106 |
|
111 | 107 | // Handle Number Literals |
112 | 108 | if (stream.match(/^[0-9\.]/, false)) { |
|
0 commit comments