Skip to content

Instantly share code, notes, and snippets.

@hokaccha
Created August 3, 2009 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hokaccha/160485 to your computer and use it in GitHub Desktop.
Save hokaccha/160485 to your computer and use it in GitHub Desktop.
if !has('ruby')
finish
endif
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=% -nargs=? BlueCloth :call <SID>BlueCloth(<line1>, <line2>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment