-
Notifications
You must be signed in to change notification settings - Fork 896
feat: Add table support and syntax highlights for markdowns #3910
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
Conversation
Closes #3896 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
// Adding node so the ...props don't have it | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ help me understand this (sorry if it's obvious 😂) we destructure node
but don't use it, how come?
does prefixing with _
fix the ESLint warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we destructure node but don't use it, how come?
Because we are getting the ...props
and we don't want props having node
.
does prefixing with _ fix the ESLint warning?
Yes, but if I use _node
it will return _node not found
because _node
is not an attribute. I could do node: _node
but I think it is more confusing than letting it as it is and adding an ignoring comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh okay, that makes sense! Thanks for explaining!
PreTag="div" | ||
{...props} | ||
> | ||
{String(children).replace(/\n$/, "")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come we have to do this .replace
? Is it to remove line breaks or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is so the highlight component can struct it properly. I got this from the react-markdown
docs https://github.com/remarkjs/react-markdown#use-custom-components-syntax-highlight
wohoo! I'm adding tables back to my templates now |
These preview images are from a storybook so the background and width can look "ugly".