-
-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-markdown can't render MathJax CHTML #745
Comments
|
@wooorm ok, if you don't want to automatically change |
yeah, no, that’s not how it works. |
Sorry, your answer was not clear for me, may you consider my latest proposal, does it sound reasonable? |
Your idea doesn’t work. Take a look at the code. |
@wooorm React-Markdown is absolutely responsible for this. react-markdown/lib/ast-to-react.js Line 371 in d044e34
If property name is React-Markdown library is all about rendering markdown in React. What I'm describing is absolutely valid scenario for React and React library supports my scenario. That is why I'm not quite sure I understand your opposition for the proposal. React supports this scenario, but you don't want even so library is all about rendering in React? |
I have no problem with your problem.
I understand that the code looks like that, but no. The plugin My concerns are about more than 500 repos. An ecosystem with lots of plugins made by users doing arbitrary things. We at unified work on many projects that integrate with React. I am concerned with how to support custom elements everywhere. Correctly. In all cases. |
I have my own implementation of The concern about backward compatibility is valid on your case, but I can't imagine a case where your current users expecting to have
|
That breaks our specification of hast — you are not supposed to do that.
I have no concern with backwards compat. I have concerns with solving this correctly. Your ideas do not solve this correctly. I am looking for ideas that solve this.
Sure.
Correct.
Please see my first comment: #745 (comment). |
Let’s track this over at remarkjs/remark-math#85. As it has more to do with what that project generates! |
This comment has been minimized.
This comment has been minimized.
Hey everybody... this is still an issue in 14+, but I thought I'd leave this here. It's definitely not a permanent solution, but it's a bandaid that works for those using Next and having this issue.
|
Initial checklist
Affected packages and versions
react-markdown: 8.0.7
Link to runnable example
https://codesandbox.io/s/crimson-architecture-8qkw9w?file=/src/app.tsx
Steps to reproduce
See the CodeSandbox link above
Expected behavior
I'm expecting MathJax CHTML to be properly rendered with React-Markdown
Actual behavior
You see blank space when rendered math expression should be.
After the investigation, I see where the problem is:
MathJax (one of the most popular libraries out there to render Latex) when outputting the result to CHTML is using custom HTML elements (example: mjx-container, mjx-math, etc).
The problem happens in ast-to-react.js when it tries to translate AST properties into react properties. In the case of
className
orclass
it will always translate it toclassName
, but React can't handleclassName
property for non-standard HTML tags.See GitHub issue here: facebook/react#4933
And instead, React will just render
classname
property instead of class.What I'm expecting from React-Markdown library in case of custom HTML tags in AST (custom tags always should have at list one dash character, so should be easy to check, like mjx-container) it should rename className to class or if class property already there don't change it to className. After this change, it should properly render in React.
Runtime
Node v17
Package manager
npm 8
OS
Windows, macOS
Build and bundle tools
Create React App
The text was updated successfully, but these errors were encountered: