More cleanup

This commit is contained in:
cte 2025-02-15 02:41:15 -08:00
parent 347c69ebe6
commit 4898b4bb9e

View file

@ -12,17 +12,7 @@ const MemoizedReactMarkdown: FC<Options> = memo(
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className,
)
const preprocessLaTeX = (content: string) => {
// Replace block-level LaTeX delimiters \[ \] with $$ $$
const blockProcessedContent = content.replace(/\\\[([\s\S]*?)\\\]/g, (_, equation) => `$$${equation}$$`)
// Replace inline LaTeX delimiters \( \) with $ $
return blockProcessedContent.replace(/\\\[([\s\S]*?)\\\]/g, (_, equation) => `$${equation}$`)
}
export function Markdown({ content }: { content: string }) {
const processedContent = preprocessLaTeX(content)
return (
<MemoizedReactMarkdown
remarkPlugins={[remarkGfm]}
@ -85,7 +75,7 @@ export function Markdown({ content }: { content: string }) {
)
},
}}>
{processedContent}
{content}
</MemoizedReactMarkdown>
)
}