(cm, text, mode, state, f, lineClasses, forceToEnd)
| 6791 | |
| 6792 | // Run the given mode's parser over a line, calling f for each token. |
| 6793 | function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) { |
| 6794 | var flattenSpans = mode.flattenSpans; |
| 6795 | if (flattenSpans == null) flattenSpans = cm.options.flattenSpans; |
| 6796 | var curStart = 0, curStyle = null; |
| 6797 | var stream = new StringStream(text, cm.options.tabSize), style; |
| 6798 | var inner = cm.options.addModeClass && [null]; |
| 6799 | if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses); |
| 6800 | while (!stream.eol()) { |
| 6801 | if (stream.pos > cm.options.maxHighlightLength) { |
| 6802 | flattenSpans = false; |
| 6803 | if (forceToEnd) processLine(cm, text, state, stream.pos); |
| 6804 | stream.pos = text.length; |
| 6805 | style = null; |
| 6806 | } else { |
| 6807 | style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses); |
| 6808 | } |
| 6809 | if (inner) { |
| 6810 | var mName = inner[0].name; |
| 6811 | if (mName) style = "m-" + (style ? mName + " " + style : mName); |
| 6812 | } |
| 6813 | if (!flattenSpans || curStyle != style) { |
| 6814 | while (curStart < stream.start) { |
| 6815 | curStart = Math.min(stream.start, curStart + 50000); |
| 6816 | f(curStart, curStyle); |
| 6817 | } |
| 6818 | curStyle = style; |
| 6819 | } |
| 6820 | stream.start = stream.pos; |
| 6821 | } |
| 6822 | while (curStart < stream.pos) { |
| 6823 | // Webkit seems to refuse to render text nodes longer than 57444 characters |
| 6824 | var pos = Math.min(stream.pos, curStart + 50000); |
| 6825 | f(pos, curStyle); |
| 6826 | curStart = pos; |
| 6827 | } |
| 6828 | } |
| 6829 | |
| 6830 | // Compute a style array (an array starting with a mode generation |
| 6831 | // -- for invalidation -- followed by pairs of end positions and |
no test coverage detected