{children};
},
- pre: ({ children }: WithChildren) => (
- {children}
- ),
+ pre: ({ children }: WithChildren) =>
+ isOnlyMermaidDiagramChild(children) ? (
+ <>{children}>
+ ) : (
+ {children}
+ ),
a: ({ href, children }: AnchorProps) => {
const isHttp = typeof href === 'string' && /^https?:\/\//i.test(href);
const handleClick = (e: React.MouseEvent) => {
@@ -231,7 +258,7 @@ function useFullComponents(
);
}
-function useCompactComponents() {
+function useCompactComponents(isDark: boolean) {
return useMemo(
() => ({
h1: ({ children }: WithChildren) => (
@@ -252,16 +279,25 @@ function useCompactComponents() {
),
li: ({ children }: WithChildren) =>
- {children}
-
- ) : (
- {children}
- );
+ const mermaidBlock = renderMermaidCodeBlock(children, className, isDark, true);
+ if (mermaidBlock) return mermaidBlock;
+
+ const { isBlock } = getCodeBlock(children, className);
+ if (isBlock) {
+ return (
+
+ {children}
+
+ );
+ }
+ return {children};
},
- pre: ({ children }: WithChildren) => {children},
+ pre: ({ children }: WithChildren) =>
+ isOnlyMermaidDiagramChild(children) ? (
+ <>{children}>
+ ) : (
+ {children}
+ ),
strong: ({ children }: WithChildren) => (
{children}
),
@@ -286,7 +322,7 @@ function useCompactComponents() {
);
},
}),
- []
+ [isDark]
);
}
@@ -300,7 +336,7 @@ export const MarkdownRenderer: React.FC
+ {chart}
+
+