import React, { FC } from "react";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import { MessageCodeBlock } from "./MessageCodeblock.js";
import { MessageMarkdownMemoized } from "./MessageMarkdownMemoized.js";
interface MessageMarkdownProps {
content: string;
}
export const MessageMarkdown: FC = ({ content }) => {
return (
{children}
;
},
img({ node, ...props }) {
return
;
},
code({ node, className, children, ...props }) {
const childArray = React.Children.toArray(children);
const firstChild = childArray[0] as React.ReactElement;
const firstChildAsString = React.isValidElement(firstChild)
? (firstChild as React.ReactElement).props.children
: firstChild;
if (firstChildAsString === "▍") {
return ▍;
}
if (typeof firstChildAsString === "string") {
childArray[0] = firstChildAsString.replace("`▍`", "▍");
}
const match = /language-(\w+)/.exec(className || "");
if (
typeof firstChildAsString === "string" &&
!firstChildAsString.includes("\n")
) {
return (
{childArray}
);
}
return (
);
},
}}
>
{content}
);
};