-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Add native video support in markdown rendering #2704
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Detect video file extensions in markdown img syntax - Render native HTML5 video element for video URLs - Support .mp4, .webm, .mov, .avi, .ogv, .m4v extensions - Fall back to image rendering for non-video files
Contributor
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.
1 issue found across 1 file
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="frontend/src/components/Markdown.tsx">
<violation number="1" location="frontend/src/components/Markdown.tsx:168">
P2: `isVideo` should check the URL’s file extension (e.g., after stripping query/fragment) instead of any substring match; otherwise images from domains containing `.mp4` are misclassified and fail to render.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
hayescode
approved these changes
Dec 4, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
Dec 4, 2025
## Summary Adds support for rendering video files directly in markdown when using image syntax (``). The markdown parser now detects video file extensions and renders a native HTML5 video element instead of trying to display videos as images. <img width="721" height="461" alt="image" src="https://github.com/user-attachments/assets/7ba80009-2b80-482f-9de9-d3493b953eaf" /> ## Changes - Modified the `img` component handler in `Markdown.tsx` to detect video file extensions - Renders native HTML5 `<video>` element with controls for video URLs - Supports common video formats: `.mp4`, `.webm`, `.mov`, `.avi`, `.ogv`, `.m4v` - Falls back to standard image rendering for non-video files ## Motivation Previously, when users included video URLs in markdown syntax like ``, the frontend was replacing them with `<img>` elements, which couldn't display the videos properly. This fix enables proper video playback directly within markdown content. ## Example ```python from chainlit import AskUserMessage, Message, on_chat_start @on_chat_start async def main(): res = await AskUserMessage(content="Please enter a video URL:", timeout=30).send() if res: video_url = res['output'] await Message( content=f"Here's your video:\n\n", ).send() ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add native video rendering in Markdown when users embed videos with image syntax. The renderer detects video URLs and shows an HTML5 video player with controls for inline playback. - **New Features** - Detects common video extensions in Markdown image nodes. - Renders a responsive HTML5 video element with controls. - Supports .mp4, .webm, .mov, .avi, .ogv, .m4v. - Falls back to standard image rendering for non-video URLs. <sup>Written for commit 83674db. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Josh Hayes <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
frontend
Pertains to the frontend.
size:M
This PR changes 30-99 lines, ignoring generated files.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for rendering video files directly in markdown when using image syntax (
). The markdown parser now detects video file extensions and renders a native HTML5 video element instead of trying to display videos as images.Changes
imgcomponent handler inMarkdown.tsxto detect video file extensions<video>element with controls for video URLs.mp4,.webm,.mov,.avi,.ogv,.m4vMotivation
Previously, when users included video URLs in markdown syntax like
, the frontend was replacing them with<img>elements, which couldn't display the videos properly. This fix enables proper video playback directly within markdown content.Example
Summary by cubic
Add native video rendering in Markdown when users embed videos with image syntax. The renderer detects video URLs and shows an HTML5 video player with controls for inline playback.
Written for commit 83674db. Summary will update automatically on new commits.