// Supports bold, italic, and links export const parseSimpleMarkdown = (input: string) => { const parts: MarkdownPart[] = [] const pattern = /(\*\*|__)(.+?)\1|(? { if (offset > lastIndex) { parts.push({ type: 'text', content: input.slice(lastIndex, offset) }) } if (bold) { parts.push({ type: 'bold', content: boldText }) } else if (italic1 || italic2) { parts.push({ type: 'italic', content: italic1 || italic2 }) } else if (url) { const urlMatch = url.match(/^(https?:\/\/[^\s]+)([.,;!?]+)$/) const urlContent = urlMatch ? urlMatch[1] : url parts.push({ type: 'link', content: urlContent }) const punctuation = urlMatch ? urlMatch[2] : '' if (punctuation) { parts.push({ type: 'text', content: punctuation }) } } lastIndex = offset + match.length return match }) if (lastIndex < input.length) { parts.push({ type: 'text', content: input.slice(lastIndex) }) } return parts } interface MarkdownPart { type: 'text' | 'bold' | 'italic' | 'link' content: string }