mdopen-mode is an Emacs minor mode that allows for an instant preview of Markdown files via mdopen. It is inspired by grip-mode but specifically aims to streamline the preview process while providing alternative approaches for handling temporary files.
- Instantly preview your Markdown files using
mdopen. - Customizable Temporary File Behavior:
- Either preview the raw Markdown file directly.
- Or generate temporary
.tmp.mdfiles stored in Emacs'temporary-file-directory(instead of placing them next to the original file).
- Automatically refreshes the preview whenever you save the file.
- Graceful cleanup of preview processes and temporary files.
- Fully compatible with Emacs'
markdown-mode.
- mdopen:
cargo install mdopen
-
Clone the repository or download the
mdopen-mode.elfile. -
Place
mdopen-mode.elin your Emacs load path. -
Add the following to your Emacs configuration (
init.el):(add-to-list 'load-path "/path/to/mdopen-mode") (require 'mdopen-mode) ;; Optionally enable mdopen-mode automatically for markdown-mode: (add-hook 'markdown-mode-hook #'mdopen-mode)
-
(Optional) If you use use-package:
(use-package mdopen-mode :load-path "/path/to/mdopen-mode" :hook (markdown-mode . mdopen-mode) :ensure t)
-
(Optional) with elpca package manager
(use-package mdopen-mode :load-path "/path/to/mdopen-mode" :hook (markdown-mode . mdopen-mode) :ensure (:fetcher github :repo "jcook3701/mdopen-mode"))
mdopen-mode provides several customization options:
- Path to the mdopen Binary
Make sure mdopen is installed on your system and accessible in your $PATH. If it is installed in a custom location, you can set the binary path:
(setq mdopen-binary-path "/custom/path/to/mdopen")- Automatic Refresh
The preview updates automatically whenever you save the file, ensuring the displayed content is always current.
(add-hook 'after-save-hook #'mdopen-refresh nil t)Here’s how you can configure mdopen-mode with your preferences:
(use-package mdopen-mode
:hook (markdown-mode . mdopen-mode)
:config
(setq mdopen-binary-path "/usr/local/bin/mdopen") ;; Replace with path to mdopen
:bind
(:map markdown-mode-command-map
("C-c C-m" . mdopen-mode))
:ensure (:fetcher github :repo "jcook3701/mdopen-mode"))Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.