-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(ui): add support for custom html tag rendering in markdown #4091
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR adds support for custom HTML tag rendering in Markdown by introducing new functionality for formatting tags and integrating custom tag handling in Markdown components. Key changes include:
- A new utility function to format custom markdown tags in chat messages.
- Addition of a custom strip tags plugin to escape non-whitelisted HTML tags.
- Updates to Markdown and MessageMarkdown components to integrate the new custom tag handling.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
ee/tabby-ui/lib/utils/chat.ts | Added formatMarkdownCustomTags function to adjust newlines for custom HTML tags. |
ee/tabby-ui/lib/constants/index.ts | Added MARKDOWN_CUSTOM_TAGS constant for whitelisting custom markdown tags. |
ee/tabby-ui/components/message-markdown/index.tsx | Integrated custom tag formatting and added a custom React component for rendering 'think'. |
ee/tabby-ui/components/message-markdown/custom-strip-tags-plugin.ts | Introduced a plugin to escape HTML tags not in the whitelist. |
ee/tabby-ui/components/markdown.tsx | Extended markdown options to support custom HTML tag rendering. |
Files not reviewed (1)
- ee/tabby-ui/package.json: Language not supported
export function customStripTagsPlugin() { | ||
return function (tree: Root) { | ||
visit(tree, 'raw', (node: Raw) => { | ||
node.value = node.value.replace(tagFilterExpression, '<$2$3') |
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.
[nitpick] The replacement string omits the leading slash captured as group1, which may lead to incorrect escaping of closing tags. Consider changing the replacement to include group1 (e.g., '<$1$3').
node.value = node.value.replace(tagFilterExpression, '<$2$3') | |
node.value = node.value.replace(tagFilterExpression, '<$1$2$3') |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
bd1fa35
to
a8dac96
Compare
based on #4075
cc @JovenSoh