feat : add support for math / science symbology via katex (#5773)

Signed-off-by: Abhijay007 <Abhijay007j@gmail.com>
This commit is contained in:
Abhijay Jain
2025-11-24 19:53:47 +05:30
committed by GitHub
parent 9a22ffe769
commit 34908226ae
4 changed files with 327 additions and 32 deletions
+14 -1
View File
@@ -2,6 +2,9 @@ import React, { useState, useEffect, useRef, memo, useMemo } from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import remarkBreaks from 'remark-breaks';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
import 'katex/dist/katex.min.css';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
// Improved oneDark theme for better comment contrast and readability
@@ -177,7 +180,17 @@ const MarkdownContent = memo(function MarkdownContent({
prose-li:m-0 prose-li:font-sans ${className}`}
>
<ReactMarkdown
remarkPlugins={[remarkGfm, remarkBreaks]}
remarkPlugins={[remarkGfm, remarkBreaks, remarkMath]}
rehypePlugins={[
[
rehypeKatex,
{
throwOnError: false,
errorColor: '#cc0000',
strict: false,
},
],
]}
components={{
a: ({ ...props }) => <a {...props} target="_blank" rel="noopener noreferrer" />,
code: MarkdownCode,