-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(ui): remove trailing code delimiters from markdown content #1597
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
fix(ui): remove trailing code delimiters from markdown content #1597
Conversation
|
|
Nice! I like this change, but I'm wondering if we should try to drop in the I think it might properly parse out the language hint and use the correct syntax highlighting. It also supports themes in it's syntax highlighting. I've been meaning to integrate it but haven't gotten around to it. |
|
I did try something like this on the Markdown component, but it didn't remove that pesky line 🤔: export function Markdown({ content }: { content: string }) {
// Clean trailing code delimiters internally
const cleanedContent = content ? content.replace(/```[a-zA-Z0-9_-]*\s*$/g, "") : content;
return (
<MemoizedReactMarkdown
remarkPlugins={[remarkGfm]}
className="custom-markdown break-words"
components={{
// ... existing components
}}>
{cleanedContent}
</MemoizedReactMarkdown>
)
} |
* let's reason together * typo * changeset * Fix type error --------- Co-authored-by: Saoud Rizwan <[email protected]>
|
Hey @monotykamary, |
Context
Trailing code delimiters (like "
tool_code" or "xml") are sometimes displayed in the markdown content when rendered in the ChatRowContent component. This is particularly common with content generated by the Gemini 2.0 thinking model. These delimiters are not meant to be displayed to the user and can make the UI look unpolished.Implementation
The implementation adds a regex-based cleaning function in the Markdown component that removes trailing code block delimiters at the end of markdown strings. The function is implemented using useMemo for performance optimization, ensuring it only runs when the markdown content changes.
The regex pattern
/```[a-zA-Z0-9_-]*\s*$/gspecifically targets only trailing delimiters at the very end of the content, preserving code blocks in the middle of the content.Screenshots
Before:
After:

How to Test
Get in Touch
If you have any questions or need clarification, please reach out on the Roo Code Discord.