bluecloth.vim
この前のvim勉強会の後にちょこっと作ったmarkdown2htmlのスクリプト。自分用に書いたやつなんでrubyが有効でblueclothもインストールされてないとダメという使い勝手悪さですけど、自分で使うぶんにはまあまあ便利。
:BlueClothでMarkdownのテキストをhtmlに変換します。範囲してすればその範囲、指定しなければ全体が対象です。
function! s:BlueCloth(line1, line2)
ruby << EOF
require 'rubygems'
require 'bluecloth'
firstline = VIM::evaluate('a:line1').to_i
lastline = VIM::evaluate('a:line2').to_i
text = []
for i in firstline .. lastline
text.push $curbuf[i]
end
parse_text = BlueCloth.new(text.join("\n")).to_html.split("\n").reverse!
parse_text.each do |line|
$curbuf.append(lastline, line)
end
for i in firstline .. lastline
$curbuf.delete(firstline)
end
EOF
endfunction
command! -range=% BlueCloth :call <SID>BlueCloth(<line1>, <line2>)
- Prev Entry:JooseでロールオーバーのJavascript書いてみた
- Next Entry:vimのhelpの引きかたメモ