markdownファイルをhtmlで見るためのスクリプト

.mdや.markdownのファイルを開くと綺麗なhtmlで見られるようにする。

markdown->html

discount(http://www.pell.portland.or.us/~orc/Code/discount/)を使う。

discountのinstall

githubから取ってきてmakeする。

git clone http://github.com/Orc/discount.git
cd discount
./configure.sh && make && sudo make install

markdownという名前でinstallされる。

discountでmarkdown->html

discountの使い方

markdown <markdown-file> 
markdown <markdown-file> -o <file>

スクリプト

作成するスクリプトは以下のような挙動。

  • .markdown or .mdならhtmlに変換->そのファイルを開く
  • それ以外はブラウザでファイルを開く

スクリプトはbrowser.scmというファイル名で作成。

code


あとは、実行権限を付加して利用する。

chmod u+x ~/bin/browser.scm
alias f="browser.scm"
f readme.md # -> /tmp/readme.htmlが作成される。そしてそれをbrowserで開く

あとでcssも適用させたいなー。