MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / runMode

Function runMode

static/js/codemirror/codemirror.js:3857–3878  ·  view source on GitHub ↗
(cm, text, mode, state, f)

Source from the content-addressed store, hash-verified

3855 // array, which contains alternating fragments of text and CSS
3856 // classes.
3857 function runMode(cm, text, mode, state, f) {
3858 var flattenSpans = cm.options.flattenSpans;
3859 var curText = "", curStyle = null;
3860 var stream = new StringStream(text, cm.options.tabSize);
3861 if (text == "" && mode.blankLine) mode.blankLine(state);
3862 while (!stream.eol()) {
3863 var style = mode.token(stream, state);
3864 if (stream.pos > 5000) {
3865 flattenSpans = false;
3866 // Webkit seems to refuse to render text nodes longer than 57444 characters
3867 stream.pos = Math.min(text.length, stream.start + 50000);
3868 style = null;
3869 }
3870 var substr = stream.current();
3871 stream.start = stream.pos;
3872 if (!flattenSpans || curStyle != style) {
3873 if (curText) f(curText, curStyle);
3874 curText = substr; curStyle = style;
3875 } else curText = curText + substr;
3876 }
3877 if (curText) f(curText, curStyle);
3878 }
3879
3880 function highlightLine(cm, line, state) {
3881 // A styles array always starts with a number identifying the

Callers 1

highlightLineFunction · 0.85

Calls 1

fFunction · 0.50

Tested by

no test coverage detected