MCPcopy Index your code
hub / github.com/documentcloud/visualsearch / processKeywords

Function processKeywords

docs/assets/highlight.js:231–252  ·  view source on GitHub ↗
(buffer, mode)

Source from the content-addressed store, hash-verified

229 }
230
231 function processKeywords(buffer, mode) {
232 if (!mode.keywords)
233 return escape(buffer);
234 var result = '';
235 var last_index = 0;
236 mode.lexemsRe.lastIndex = 0;
237 var match = mode.lexemsRe.exec(buffer);
238 while (match) {
239 result += escape(buffer.substr(last_index, match.index - last_index));
240 var keyword_match = keywordMatch(mode, match);
241 if (keyword_match) {
242 keyword_count += keyword_match[1];
243 result += '<span class="'+ keyword_match[0] +'">' + escape(match[0]) + '</span>';
244 } else {
245 result += escape(match[0]);
246 }
247 last_index = mode.lexemsRe.lastIndex;
248 match = mode.lexemsRe.exec(buffer);
249 }
250 result += escape(buffer.substr(last_index, buffer.length - last_index));
251 return result;
252 }
253
254 function processBuffer(buffer, mode) {
255 if (mode.subLanguage && languages[mode.subLanguage]) {

Callers 1

processBufferFunction · 0.85

Calls 2

keywordMatchFunction · 0.85
escapeFunction · 0.70

Tested by

no test coverage detected