MCPcopy
hub / github.com/jstat/jstat / output

Function output

doc/assets/sh_main.js:93–131  ·  view source on GitHub ↗
(s, style)

Source from the content-addressed store, hash-verified

91 var currentStyle = null;
92
93 var output = function(s, style) {
94 var length = s.length;
95 // this is more than just an optimization - we don't want to output empty <span></span> elements
96 if (length === 0) {
97 return;
98 }
99 if (! style) {
100 var stackLength = patternStack.length;
101 if (stackLength !== 0) {
102 var pattern = patternStack[stackLength - 1];
103 // check whether this is a state or an environment
104 if (! pattern[3]) {
105 // it's not a state - it's an environment; use the style for this environment
106 style = pattern[1];
107 }
108 }
109 }
110 if (currentStyle !== style) {
111 if (currentStyle) {
112 tags[numTags++] = {pos: pos};
113 if (currentStyle === 'sh_url') {
114 sh_setHref(tags, numTags, inputString);
115 }
116 }
117 if (style) {
118 var clone;
119 if (style === 'sh_url') {
120 clone = a.cloneNode(false);
121 }
122 else {
123 clone = span.cloneNode(false);
124 }
125 clone.className = style;
126 tags[numTags++] = {node: clone, pos: pos};
127 }
128 }
129 pos += length;
130 currentStyle = style;
131 };
132
133 var endOfLinePattern = /\r\n|\r|\n/g;
134 endOfLinePattern.lastIndex = 0;

Callers 1

sh_highlightStringFunction · 0.85

Calls 1

sh_setHrefFunction · 0.85

Tested by

no test coverage detected