import React from "react" import remarkGfm from "remark-gfm" import remarkMath from "remark-math" import { CodeBlock, InlineCode } from "../atoms/code-block" import { MemoizedReactMarkdown } from "../organisms/memorized-markdown" import Blockquote from "./blockquote" import Strong from "./strong" import Text from "./text" export function Markdown({ children, components, }: { children: string | string[] | React.ReactNode[] components?: any }) { const snippet = children as string const markdown = snippet.replace(/\n/g, "\n\n") return ( {children} }, h1({ children }) { return

{children}

}, h2({ children }) { return

{children}

}, strong({ children }) { return {children} }, blockquote({ children }) { return
{children}
}, code({ inline, className, children, ...props }) { if (children.length) { if (children[0] == "▍") { return ( ) } children[0] = (children[0] as string).replace("`▍`", "▍") } const match = /language-(\w+)/.exec(className || "") const filenameMatch = /filename="(\w+.\w+)"/.exec(className || "") if (inline) { return ( {children} ) } return ( ) }, ...components, }} > {markdown}
) }