MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / addCodeBlockWrappers

Function addCodeBlockWrappers

ui/src/components/MarkdownContent.tsx:72–82  ·  view source on GitHub ↗
(html: string)

Source from the content-addressed store, hash-verified

70const 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
72function 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
84interface MarkdownContentProps {
85 text: string

Callers 1

MarkdownContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected