Sha256: 1e8ffd6306f77abfb16817e192dd09ef88f43e533dd7407cb23a9bc94f3abd1a

Contents?: true

Size: 1.57 KB

Versions: 100

Compression:

Stored size: 1.57 KB

Contents

CodeMirror.runMode = function(string, modespec, callback, options) {
  var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
  var isNode = callback.nodeType == 1;
  var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
  if (isNode) {
    var node = callback, accum = [], col = 0;
    callback = function(text, style) {
      if (text == "\n") {
        accum.push("<br>");
        col = 0;
        return;
      }
      var escaped = "";
      // HTML-escape and replace tabs
      for (var pos = 0;;) {
        var idx = text.indexOf("\t", pos);
        if (idx == -1) {
          escaped += CodeMirror.htmlEscape(text.slice(pos));
          col += text.length - pos;
          break;
        } else {
          col += idx - pos;
          escaped += CodeMirror.htmlEscape(text.slice(pos, idx));
          var size = tabSize - col % tabSize;
          col += size;
          for (var i = 0; i < size; ++i) escaped += " ";
          pos = idx + 1;
        }
      }

      if (style) 
        accum.push("<span class=\"cm-" + CodeMirror.htmlEscape(style) + "\">" + escaped + "</span>");
      else
        accum.push(escaped);
    }
  }
  var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
  for (var i = 0, e = lines.length; i < e; ++i) {
    if (i) callback("\n");
    var stream = new CodeMirror.StringStream(lines[i]);
    while (!stream.eol()) {
      var style = mode.token(stream, state);
      callback(stream.current(), style, i, stream.start);
      stream.start = stream.pos;
    }
  }
  if (isNode)
    node.innerHTML = accum.join("");
};

Version data entries

100 entries across 100 versions & 6 rubygems

Version Path
burp_cms-1.3.23 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.22 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.21 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.20 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.19 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.18 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.17 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.16 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.15 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.14 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.13 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.12 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.11 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.10 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.9 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.8 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
omf_web-0.9.9 share/htdocs/vendor/CodeMirror-2.32/lib/util/runmode.js
omf_web-0.9.8 share/htdocs/vendor/CodeMirror-2.32/lib/util/runmode.js
burp_cms-1.3.7 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js
burp_cms-1.3.6 app/assets/packages/burp/editing/dep/CodeMirror-2.3/lib/util/runmode.js