Skip to content

An Emacs package for embedding various content in Org-mode.

Notifications You must be signed in to change notification settings

yibie/org-embed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

org-embed

An Emacs package for embedding various content in Org-mode.

figure1.png

Features

  • 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

Supported Video Platforms

  • YouTube
  • Bilibili
  • Vimeo
  • Dailymotion
  • TED Talks
  • Local video files

Other Supported Content

  • Any webpage
  • PDF files (local)

Installation

Place this package in your Emacs load path, then add the following to your configuration file:

(require 'org-embed)

Usage

Click on the link or use C-c C-o to open embedded content.

Link Format

You can directly enter links in the following format in your Org file:

[[org-embed:type:URL-or-path]]

Where:

  • type can be video, local-video, webpage, or pdf
  • 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]]

Embedding Online Videos

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 or https://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

Embedding Local Videos

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).

Embedding Webpages

M-x org-embed-webpage

Then enter the webpage URL.

Embedding PDFs

M-x org-embed-pdf

Then enter the local path of the PDF file.

Customization

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

Extension

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 URL
  • my-platform-handler is a function that takes a URL, width, and height, and returns the embedded HTML content

⚠️KNOWN ISSUES

  • 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.

Cleaning Embedded Content

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.

File Structure

  • org-embed.el - Main entry file
  • org-embed-core.el - Core functionality module
  • org-embed-rules.el - Content processing rule set

Dependencies

  • Emacs 25.1 or higher
  • Emacs compiled with xwidget-webkit support

Acknowledgment

Thank to RadioNoiseE for the inspiring ideas he provided and his contributions to this project.

License

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/.

About

An Emacs package for embedding various content in Org-mode.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published