MCPcopy
hub / github.com/nwutils/nw-sample-apps / span_

Function span_

mini-code-edit/cm/lib/codemirror.js:2466–2493  ·  view source on GitHub ↗
(text, style)

Source from the content-addressed store, hash-verified

2464 getHTML: function(makeTab, wrapAt, wrapId, wrapWBR) {
2465 var html = [], first = true, col = 0;
2466 function span_(text, style) {
2467 if (!text) return;
2468 // Work around a bug where, in some compat modes, IE ignores leading spaces
2469 if (first && ie && text.charAt(0) == " ") text = "\u00a0" + text.slice(1);
2470 first = false;
2471 if (text.indexOf("\t") == -1) {
2472 col += text.length;
2473 var escaped = htmlEscape(text);
2474 } else {
2475 var escaped = "";
2476 for (var pos = 0;;) {
2477 var idx = text.indexOf("\t", pos);
2478 if (idx == -1) {
2479 escaped += htmlEscape(text.slice(pos));
2480 col += text.length - pos;
2481 break;
2482 } else {
2483 col += idx - pos;
2484 var tab = makeTab(col);
2485 escaped += htmlEscape(text.slice(pos, idx)) + tab.html;
2486 col += tab.width;
2487 pos = idx + 1;
2488 }
2489 }
2490 }
2491 if (style) html.push('<span class="', style, '">', escaped, "</span>");
2492 else html.push(escaped);
2493 }
2494 var span = span_;
2495 if (wrapAt != null) {
2496 var outPos = 0, open = "<span id=\"" + wrapId + "\">";

Callers 1

codemirror.jsFile · 0.85

Calls 2

makeTabFunction · 0.85
htmlEscapeFunction · 0.70

Tested by

no test coverage detected