search
LoginSignup
42

More than 5 years have passed since last update.

posted at

emacsの中でmarkdownをpreviewする

markdownファイルをgripでレンダリングしてemcas-w3mで開く

Gyazo

emacsでmarkdownを書いて、emacsの中でpreviewする方法。
emacsの中から出たくない人向け。

準備

markdown-modeとか
emacs-w3mとか
gripを入れておきます.

.emacs

.emacsに以下のようなものを追加

(require 'w3m)
(require 'markdown-mode)

(defun w3m-browse-url-other-window (url &optional newwin)
  (let ((w3m-pop-up-windows t))
    (if (one-window-p) (split-window))
    (other-window 1)
    (w3m-browse-url url newwin)))

(defun markdown-render-w3m (n)
  (interactive "p")
  (message (buffer-file-name))
  (call-process "/usr/local/bin/grip" nil nil nil
                "--gfm" "--export"
                (buffer-file-name)
                "/tmp/grip.html")
  (w3m-browse-url-other-window "file://tmp/grip.html")
  )
(define-key markdown-mode-map "\C-c \C-c" 'markdown-render-w3m)

そうするとC-c C-cでemacsの中でmarkdownがpreviewできます.

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
42