Skip to content

Instantly share code, notes, and snippets.

@hokaccha
Created August 3, 2009 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hokaccha/160493 to your computer and use it in GitHub Desktop.
Save hokaccha/160493 to your computer and use it in GitHub Desktop.
function! g:Hatena(arg, line1, line2)
perl << EOF
use Text::Hatena;
my ($success, $firstline) = VIM::Eval('a:line1');
my ($success, $lastline) = VIM::Eval('a:line2');
my $base_text = join "\n", $curbuf->Get($firstline .. $lastline);
my $parse_text = Text::Hatena->parse($base_text);
my @html = split("\n", $parse_text);
shift @html;
pop @html;
$curbuf->Append($lastline, @html);
$curbuf->Delete($firstline, $lastline);
EOF
endfunction
command! -range=% -nargs=? Hatena :call g:Hatena(<q-args>, <line1>, <line2>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment