diff --git a/src/components/MarkdownTabs.tsx b/src/components/MarkdownTabs.tsx index 10ca463..de0e7f5 100644 --- a/src/components/MarkdownTabs.tsx +++ b/src/components/MarkdownTabs.tsx @@ -47,6 +47,8 @@ const markdownSchema = { img: ["src", "alt", "title", "width", "height"], + code: [...(defaultSchema.attributes?.code || []), "className"], + "*": ["title", "align"], }, }; @@ -105,9 +107,13 @@ function MarkdownContent({ content }: { content: string }) { ); }, - code({ node, inline, className, children, ...props }: any) { + code({ node, className, children, ...props }: any) { const match = /language-(\w+)/.exec(className || ""); - return !inline && match ? ( + const isInline = + !match || + (node?.position?.start?.line === node?.position?.end?.line && + !String(children).includes("\n")); + return !isInline && match ? (