39
41

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

emacsの中でmarkdownをpreviewする

Posted at

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できます.

39
41
2

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
  3. You can use dark theme
What you can do with signing up
39
41

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?