43
Help us understand the problem. What are the problem?

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
43
Help us understand the problem. What are the problem?