OLD | NEW |
1 // Content of the function is equal to runmode-standalone.js file | 1 // Content of the function is equal to runmode-standalone.js file |
2 // from CodeMirror distribution | 2 // from CodeMirror distribution |
3 (function(window) { | 3 (function(window) { |
| 4 // CodeMirror, copyright (c) by Marijn Haverbeke and others |
| 5 // Distributed under an MIT license: http://codemirror.net/LICENSE |
| 6 |
4 window.CodeMirror = {}; | 7 window.CodeMirror = {}; |
5 | 8 |
6 (function() { | 9 (function() { |
7 "use strict"; | 10 "use strict"; |
8 | 11 |
9 function splitLines(string){ return string.split(/\r?\n|\r/); }; | 12 function splitLines(string){ return string.split(/\r?\n|\r/); }; |
10 | 13 |
11 function StringStream(string) { | 14 function StringStream(string) { |
12 this.pos = this.start = 0; | 15 this.pos = this.start = 0; |
13 this.string = string; | 16 this.string = string; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } else { | 138 } else { |
136 node.appendChild(document.createTextNode(content)); | 139 node.appendChild(document.createTextNode(content)); |
137 } | 140 } |
138 }; | 141 }; |
139 } | 142 } |
140 | 143 |
141 var lines = splitLines(string), state = (options && options.state) || CodeMirr
or.startState(mode); | 144 var lines = splitLines(string), state = (options && options.state) || CodeMirr
or.startState(mode); |
142 for (var i = 0, e = lines.length; i < e; ++i) { | 145 for (var i = 0, e = lines.length; i < e; ++i) { |
143 if (i) callback("\n"); | 146 if (i) callback("\n"); |
144 var stream = new CodeMirror.StringStream(lines[i]); | 147 var stream = new CodeMirror.StringStream(lines[i]); |
| 148 if (!stream.string && mode.blankLine) mode.blankLine(state); |
145 while (!stream.eol()) { | 149 while (!stream.eol()) { |
146 var style = mode.token(stream, state); | 150 var style = mode.token(stream, state); |
147 callback(stream.current(), style, i, stream.start, state); | 151 callback(stream.current(), style, i, stream.start, state); |
148 stream.start = stream.pos; | 152 stream.start = stream.pos; |
149 } | 153 } |
150 } | 154 } |
151 }; | 155 }; |
152 })(); | 156 })(); |
153 | |
154 }(this)) | 157 }(this)) |
OLD | NEW |