-
Notifications
You must be signed in to change notification settings - Fork 8
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
Feat: DO-3456 extract code from markdown and use code viewer in chat component #348
Feat: DO-3456 extract code from markdown and use code viewer in chat component #348
Conversation
* A function to parse markdown such that code blocks return CodeViewer component | ||
* @param message | ||
*/ | ||
function parseMarkdown(message: string): React.ReactNode[] { |
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.
I think we could simply utilize the tag->component map like in the example here https://github.com/remarkjs/react-markdown?tab=readme-ov-file#use-custom-components-syntax-highlight rather than relying on our own regex?
Updated the approach slightly. Baked the code display into the base markdown display instead, if the code block has a specified language e.g. "```python...". @tamara-causalens let me know if this behaviour looks okay. |
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.
Looks amazing! 😍
Motivation and Context
Improve the visuals of code blocks rendered within
Chat
component, and allow users to easily copy its contentImplementation Description
Added a parser that breaks the message string intoMarkdown
andCodeViewer
components. This is only applied to the displayed message so that when editing users still have full control of the markdown string and can make changes if neededUpdated base markdown component to use
CodeViewer
for code blocks with a specified language.Any new dependencies Introduced
How Has This Been Tested?
Locally on storybook
PR Checklist:
Screenshots (if appropriate):