import { useMemo } from 'react' import { marked, type Tokens } from 'marked' import { escapeHtml, highlightCodeLines, isHighlightable } from '../chat/highlightCode' type Props = { content: string } const renderer = new marked.Renderer() renderer.code = function ({ text, lang }: Tokens.Code) { const languageLabel = escapeHtml(lang || 'code') const lines = text.split('\n') const hasLanguage = isHighlightable(lang) const highlightedLines = highlightCodeLines(text, lang) // Show line numbers only when language is known (actual code). // Plain text, file trees, command output etc. look better without them. const body = hasLanguage ? highlightedLines .map((line, index) => `