import { jsx, renderToHtml, type JSXNode } from '@zhin.js/jsx'; import { htmlToDOM, Element, Text, type DOMNode } from 'html-react-parser'; import { renderImage, colorBox } from './render-image.js'; import { CodeBlock } from '../src/code-block.js'; import { ThemeProvider } from '../src/theme.js'; function textContent(html: string): string { const text = (node: DOMNode): string => node instanceof Text ? node.data : node instanceof Element ? node.children.map(child => text(child as DOMNode)).join('') : ''; return htmlToDOM(html).map(text).join(''); } describe('CodeBlock', () => { it('renders actual Shiki token colors and escapes code without injecting HTML', async () => { const html = await renderToHtml(jsx(CodeBlock, { source: 'const html = "