mehdisadeghi / react-mathjax-preview

The MathJax React component you were looking for.
https://mehdisadeghi.github.io/react-mathjax-preview/
MIT License
49 stars 30 forks source link

Unexpected text node: '2', can't use annotation tags #29

Open henok-tesfaye opened 4 years ago

henok-tesfaye commented 4 years ago

<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>1</mn><mo>=</mo><semantics><mrow><mn>2</mn></mrow><annotation encoding="text/plain">2</annotation></semantics><mspace linebreak="newline"/><mn>2</mn><mo>=</mo><semantics><mrow><mn>3</mn></mrow><annotation encoding="text/plain">3</annotation></semantics></math>

I tried this math formula here, https://focused-tesla-b6fe0a.netlify.com/, and It shows Unexpected text node: '2'. But when I delete all the annotation tags it works?

mehdisadeghi commented 4 years ago

Thanks for reporting this. This is a configuration problem in this code. Configuring MathJax in React is not straightforward and I didn't find a quick fix for that. I will try to address this issue when updating to MathJax 3. Meanwhile feel free to submit a PR if you have a solution.

udit-compro commented 3 years ago

What is the expected output? The above mentioned link is not working.

mehdisadeghi commented 3 years ago

@udit-compro the new demo page is here: https://mehdisadeghi.github.io/react-mathjax-preview/. Just try the mathml mentioned above there. Apparently the given matml produces an error.

udit-compro commented 3 years ago

@mehdisadeghi Thanks. I will see if I am able to fix this. The issue is because of DOMPurify that's all I know as of now. We might need to pass some sanitizationConfig which will fix this issue.