LoginSignup
5
5

More than 5 years have passed since last update.

Vimで:makeでpandocを使ってmarkdownからhtmlを出力する設定

Posted at

特にまとめておくまでもないことなんだけども、健忘録として。
MacOSXとかで

brew install pandoc

を実行してpandocをインストールしておく。以下の様なスクリプトを用意。名前は適当にmake_markdown.pyとかにして適当なフォルダにおいておく。

import sys
import glob
import commands

param = sys.argv
if (len(param) == 2):
    f = param[1]
    h = f[0:-3] + '.html'
    command = "pandoc %s -s -o %s" % (f, h)
    commands.getoutput(command)
    quit()

vimrcに以下を追加。

au FileType markdown setlocal makeprg=python\ ~/dotfiles/make_markdown.py\ %

ここでは、~/dotfiles/make_markdown.pyに設置した。
これでa.mdに対してa.htmlのようなファイルを:makeコマンドで発行してくれるようになる。
もっとリッチなことをしたい方はおそらくvim-pandocなどをインストールした方がよさそう。

5
5
1

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
5
5