Atul
Atul

Reputation: 688

React-markdown with rehype-mathjax fails for certain eqautions

I am using react-markdown to render chats. I want to render the below string

"Sure thing! Here's a mathematical formula that includes powers, roots, subscripts, and the Greek letter lambda (λ):\n\n$$\lambda^2 x^{3/2} + \frac{1}{x^{1/2}} = \lambda^2 x^{3/2} + \frac{1}{\sqrt[3]{x}}$$\n\nIn this formula, λ is a scalar and x is a positive real number. The formula includes powers (2 and 3/2), roots (1/2), and subscripts (3).\n\nI hope this helps! Let me know if you have any questions or need further assistance. \n "

It gets rendered properly but when I instrument my react app with Opentelemetry. I get the below error

error_pic

But strangely enough the below string is always rendered properly

"$x^2 + y^2 = z^2 $"

My node version is v20.10.0

<ReactMarkdown
   remarkPlugins={[remarkGfm, remarkMath]}
   rehypePlugins={[rehypeMathjax]}
   components={{ ...
.../>

Upvotes: 1

Views: 155

Answers (0)

Related Questions