Skip to content

Edit document as other format, in Emacs, using Pandoc

License

Notifications You must be signed in to change notification settings

etern/edit-as-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Edit As Format

Introduction

Edit document as other format, as long as your format is supported by Pandoc.

You love OrgMode, but have to use markdown sometimes, open your markdown file in emacs, M-x edit-as-format-org, happy writing!

https://s3.bmp.ovh/imgs/2022/02/4411a7373b3707e6.gif

Features

  • Edit document as other format in a separate buffer, with changes commited back to original buffer
  • Handle selected region or whole buffer
  • edit-as-format-org edit current buffer as org document
  • edit-as-format edit current buffer as other format, prompt for target format
  • supported formats
    • default format list use intersection of pandoc --list-input-formats and pandoc --list-output-formats
    • however, not all that list is supported, especially non-textual formats
    • basically, markup language formats will works OK
    • it’s customizable edit-as-format-formats

Configuration

Prerequisite

  • install Pandoc, make it accessible from PATH

Use package from Melpa

(use-package edit-as-format
  :ensure t
  :bind ("C-c e e" . edit-as-format))

Custom commands can be created easily with edit-as-format, examples:

(defun edit-org-as-markdown ()
  (interactive)
  (edit-as-format "org" "markdown"))
(defun edit-as-markdown ()
  (interactive)
  (edit-as-format nil "gfm")

Key Bindings

This package uses edit-indirect for editing, the key binding in edit-indirect-mode-map resembles org-src-mode-map

  • C-c ’ edit-indirect-commit
  • C-c C-c edit-indirect-commit
  • C-c C-k edit-indirect-abort
  • C-x C-s edit-indirect-save

Bind key to edit-as-format edit-as-format-org for convenient access

(global-set-key (kbd "C-c e e") 'edit-as-format)
(global-set-key (kbd "C-c e o") 'edit-as-format-org)

Optionally, unbind edit-indirect-commit, give [C-c ‘] back to org-edit-special in org-mode

(unbind-key "C-c '" edit-indirect-mode-map)

Alternatives

  • org-pandoc-import gives a rather complete solution, it has many good features, in contrast, edit-as-format takes a simpler way: pandoc + edit-indirect (and takes some code from org-pandoc-import, great thanks).

Known issues

  • markdown redundant spaces, maybe write pandoc filter ?

About

Edit document as other format, in Emacs, using Pandoc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published