(text: string, symbolLookup: SymbolLookup)
| 69 | * @internal Exported for testing |
| 70 | */ |
| 71 | export function parseJsDocLinks(text: string, symbolLookup: SymbolLookup): string { |
| 72 | let result = escapeHtml(text) |
| 73 | |
| 74 | result = result.replace(/\{@link\s+([^\s}]+)(?:\s+([^}]+))?\}/g, (_, target, label) => { |
| 75 | const displayText = label || target |
| 76 | |
| 77 | // External URL |
| 78 | if (target.startsWith('http://') || target.startsWith('https://')) { |
| 79 | return `<a href="${target}" target="_blank" rel="noreferrer" class="docs-link">${displayText}</a>` |
| 80 | } |
| 81 | |
| 82 | // Internal symbol reference |
| 83 | const symbolId = symbolLookup.get(target) |
| 84 | if (symbolId) { |
| 85 | return `<a href="#${symbolId}" class="docs-symbol-link">${displayText}</a>` |
| 86 | } |
| 87 | |
| 88 | // Unknown symbol |
| 89 | return `<code class="docs-symbol-ref">${displayText}</code>` |
| 90 | }) |
| 91 | |
| 92 | return result |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Render simple markdown-like formatting. |
no test coverage detected