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
Typography Markdown support? #12290
Comments
@9oelM You could perhaps take advantage of Alternatively there are existing React components such as https://github.com/rexxars/react-markdown |
Also, a better pattern is probably to do it the other way around. At least, it's what we have been doing on the project I'm working on. We have a markdown parser that uses the right typography variant based on the context automatically. |
This comment has been minimized.
This comment has been minimized.
Thanks! Will take reference of your example. |
Thanks, this is super helpful. Things are working as expected, however, I am getting the following warning:
Any thoughts? Is this a problem with the Typography component itself? |
@benshanahan1 We have added a Markdown demo in the repository. You can find the source: material-ui/docs/src/pages/premium-themes/onepirate/modules/components/Markdown.tsx Line 48 in 3f8c1a4
It's using markdown-to-jsx over react-markdown as it's faster and lighter.
Alternatively, if you really need performance, you would need to use a pure HTML approach, it's what we do for the docs:
|
I'll check it out, thank you! |
This comment has been minimized.
This comment has been minimized.
@oliviertassinari Hi, regarding overriding default nodes to Typography, can your demo also be implemented using |
react-markdown was really slow, and doesn't seem to have changed. I would avoid it. |
For those sticking with react-markdown, you'll need to use the
or if you need to apply additional props to
The full list of overridable renderers is available in the Node types section of the documentation. |
Context
Typography
component.Typography
components with props you want to put in, such asvariant
prop.markdown
prop (and some supplementary props) on Typography component and let it render the markdown with all kinds of headings and variants?Current Behavior
Currently, you've gotta do something like:
If you are writing generic texts.
Suggestion
Instead of writing
Typography
components all over, can't we do something like:Typography
is a real pain if you are trying to write many texts with various props and heading types.Thanks!
The text was updated successfully, but these errors were encountered: