{code}
)}
when it was the sole child of
,
was kept, adding // unwanted vertical spacing inside list items. // This version strips
wrappers from ALL children, regardless of count.
function unwrapParagraphs(children: React.ReactNode): React.ReactNode {
return React.Children.map(children, (child) => {
if (React.isValidElement(child) && child.type === "p") {
return (child.props as { children?: React.ReactNode }).children;
}
return child;
});
}
export const Markdown = memo(function Markdown({ content, className, enableEnrichment = true, enableLocalImageRender = true }: MarkdownProps) {
const isDark = useIsDark();
const [fileMap, setFileMap] = useState {enrich(children)}{enrich(children)} ,
th: ({ children }) => {enrich(children)} ,
h1: ({ children }) => {children}
,
h2: ({ children }) => {children}
,
h3: ({ children }) => {children}
,
ul: ({ children }) => {children}
,
ol: ({ children }) => {children}
,
a: ({ href, children }) => (
{children}
),
blockquote: ({ children }) => {children}
,
table: ({ children }) => (
{children}
,
img: ({ src, alt }) => {
if (!src) return null;
if (!enableLocalImageRender) return {src};
if (getMediaTypeFromSrc(src) === "video") {
return isLocalPath(src) ?
{showColor ?
);
}
return