An Emacs package for embedding various content in Org-mode.
- Support for embedding videos from various platforms in Org-mode
- Support for embedding local video files in Org-mode (separate command)
- Support for embedding any webpage in Org-mode
- Support for embedding PDF files in Org-mode
- Modular design, easily extensible to support more content types
- YouTube
- Bilibili
- Vimeo
- Dailymotion
- TED Talks
- Local video files
- Any webpage
- PDF files (local)
Place this package in your Emacs load path, then add the following to your configuration file:
(require 'org-embed)
Click on the link or use C-c C-o
to open embedded content.
You can directly enter links in the following format in your Org file:
[[org-embed:type:URL-or-path]]
Where:
type
can bevideo
,local-video
,webpage
, orpdf
URL-or-path
is the address or file path of the content to embed
For example:
[[org-embed:video:https://youtube.com/watch?v=VIDEO_ID]] [[org-embed:local-video:/path/to/video.mp4]] [[org-embed:webpage:https://example.com]] [[org-embed:pdf:/path/to/document.pdf]]
In addition to directly entering links, you can also use the interactive command:
M-x org-embed-video
Then enter the video URL, for example:
- YouTube:
https://youtube.com/watch?v=VIDEO_ID
orhttps://youtu.be/VIDEO_ID
- Bilibili:
https://bilibili.com/video/BVID
- Vimeo:
https://vimeo.com/VIDEO_ID
- Dailymotion:
https://dailymotion.com/video/VIDEO_ID
- TED:
https://ted.com/talks/TALK_ID
For local video files, use the dedicated command:
M-x org-embed-local-video
Then enter the path to your local video file (mp4, webm, ogv, mov, mkv, avi).
M-x org-embed-webpage
Then enter the webpage URL.
M-x org-embed-pdf
Then enter the local path of the PDF file.
You can customize the default dimensions of the content through the following variables:
(setq org-embed-video-width 800) ; Default is 640
(setq org-embed-video-height 450) ; Default is 360
(setq org-embed-webpage-width 1024) ; Default is 800
(setq org-embed-webpage-height 768) ; Default is 600
(setq org-embed-pdf-width 800) ; Default is 800
(setq org-embed-pdf-height 1200) ; Default is 1000
You can add support for more content types by adding new rules:
(org-embed-register-rule 'my-platform
#'my-platform-matcher
#'my-platform-handler)
Where:
my-platform-matcher
is a function that takes a URL and returns non-nil if it can handle the URLmy-platform-handler
is a function that takes a URL, width, and height, and returns the embedded HTML content
- incompatibility with org-modern-mode
When using org-embed, please note that it may not display properly if org-modern-mode is enabled. If you encounter display issues, try disabling org-modern-mode.
You can use the following commands to clean up embedded content:
M-x org-embed-clean-at-point ; Clean up embedded content at cursor M-x org-embed-clean-all ; Clean up all embedded content in the current buffer
**Note**: When using `org-embed-clean-at-point`, make sure your cursor is positioned before or at the xwidget you want to clean. If the cursor is not at a xwidget, the function will search forward for the next xwidget.
org-embed.el
- Main entry fileorg-embed-core.el
- Core functionality moduleorg-embed-rules.el
- Content processing rule set
- Emacs 25.1 or higher
- Emacs compiled with xwidget-webkit support
Thank to RadioNoiseE for the inspiring ideas he provided and his contributions to this project.
Copyright © 2025 Yibie
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.