import * as React from "react"; import { cn } from "@/components/ui/utils"; interface FormattedDescriptionProps { content: string; className?: string; } /** * FormattedDescription Component * * Renders HTML content with proper styling for lists, tables, and other formatted content. * Use this component to display descriptions that may contain HTML formatting. */ export function FormattedDescription({ content, className }: FormattedDescriptionProps) { const processedContent = React.useMemo(() => { if (!content) return ''; // Wrap tables that aren't already wrapped in a scrollable container using regex // Match tags that aren't already inside a .table-wrapper let processed = content; // Pattern to match table tags that aren't already wrapped const tablePattern = /]*>[\s\S]*?<\/table>/gi; processed = processed.replace(tablePattern, (match) => { // Check if this table is already wrapped if (match.includes('table-wrapper')) { return match; } // Wrap the table in a scrollable container return `
${match}
`; }); return processed; }, [content]); if (!content) return null; return (
); }