(codeBlock)
| 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(/("[^&]*?"|'[^&]*?'|`[^`]*?`)/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) { |
nothing calls this directly
no outgoing calls
no test coverage detected