Skip to content

Instantly share code, notes, and snippets.

@soh335
Forked from hokaccha/bluecloth.vim
Created August 4, 2009 05:42
Show Gist options
  • Save soh335/161045 to your computer and use it in GitHub Desktop.
Save soh335/161045 to your computer and use it in GitHub Desktop.
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>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment