| 70 | const CHECK_ICON = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>` |
| 71 | |
| 72 | function addCodeBlockWrappers(html: string): string { |
| 73 | return html.replace( |
| 74 | /<pre><code class="hljs language-(\w+)">([\s\S]*?)<\/code><\/pre>/g, |
| 75 | (_, lang, code) => |
| 76 | `<div class="code-block-wrapper"><div class="code-header"><span>${lang}</span><button class="code-copy-btn" data-code>${COPY_ICON} Copy</button></div><pre><code class="hljs language-${lang}">${code}</code></pre></div>`, |
| 77 | ).replace( |
| 78 | /<pre><code class="hljs">([\s\S]*?)<\/code><\/pre>/g, |
| 79 | (_, code) => |
| 80 | `<div class="code-block-wrapper"><div class="code-header"><span>code</span><button class="code-copy-btn" data-code>${COPY_ICON} Copy</button></div><pre><code class="hljs">${code}</code></pre></div>`, |
| 81 | ) |
| 82 | } |
| 83 | |
| 84 | interface MarkdownContentProps { |
| 85 | text: string |