MCPcopy
hub / github.com/csev/py4e / span_

Function span_

tools/pythonauto/static/codemirrorepl/codemirrorepl.js:2666–2693  ·  view source on GitHub ↗
(text, style)

Source from the content-addressed store, hash-verified

2664 getHTML: function(makeTab, wrapAt, wrapId, wrapWBR) {
2665 var html = [], first = true, col = 0;
2666 function span_(text, style) {
2667 if (!text) return;
2668 // Work around a bug where, in some compat modes, IE ignores leading spaces
2669 if (first && ie && text.charAt(0) == " ") text = "\u00a0" + text.slice(1);
2670 first = false;
2671 if (text.indexOf("\t") == -1) {
2672 col += text.length;
2673 var escaped = htmlEscape(text);
2674 } else {
2675 var escaped = "";
2676 for (var pos = 0;;) {
2677 var idx = text.indexOf("\t", pos);
2678 if (idx == -1) {
2679 escaped += htmlEscape(text.slice(pos));
2680 col += text.length - pos;
2681 break;
2682 } else {
2683 col += idx - pos;
2684 var tab = makeTab(col);
2685 escaped += htmlEscape(text.slice(pos, idx)) + tab.html;
2686 col += tab.width;
2687 pos = idx + 1;
2688 }
2689 }
2690 }
2691 if (style) html.push('<span class="', style, '">', escaped, "</span>");
2692 else html.push(escaped);
2693 }
2694 var span = span_;
2695 if (wrapAt != null) {
2696 var outPos = 0, open = "<span id=\"" + wrapId + "\">";

Callers 1

codemirrorepl.jsFile · 0.85

Calls 3

htmlEscapeFunction · 0.85
makeTabFunction · 0.85
sliceMethod · 0.80

Tested by

no test coverage detected