MCPcopy Create free account
hub / github.com/Trae-AI/stream-to-river / highlightJavaScript

Function highlightJavaScript

apiservice/resource/repome/scripts.js:1488–1504  ·  view source on GitHub ↗
(codeBlock)

Source from the content-addressed store, hash-verified

1486
1487 // Highlight JavaScript
1488 highlightJavaScript(codeBlock) {
1489 const content = codeBlock.textContent;
1490 const escaped = this.escapeHtml(content);
1491
1492 const highlighted = escaped
1493 // Keywords
1494 .replace(/\b(const|let|var|function|if|else|for|while|return|class|import|export|from|async|await|try|catch|finally)\b/g, '<span class="js-keyword">$1</span>')
1495 // Strings (handle escaped quotes)
1496 .replace(/(&quot;[^&]*?&quot;|&#x27;[^&]*?&#x27;|`[^`]*?`)/g, '<span class="js-string">$1</span>')
1497 // Numbers
1498 .replace(/\b(\d+\.?\d*)\b/g, '<span class="js-number">$1</span>')
1499 // Comments
1500 .replace(/(\/\/[^\n]*)/g, '<span class="js-comment">$1</span>')
1501 .replace(/(\/\*[\s\S]*?\*\/)/g, '<span class="js-comment">$1</span>');
1502
1503 codeBlock.innerHTML = highlighted;
1504 },
1505
1506 // Highlight Go
1507 highlightGo(codeBlock) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected