Skip to content

Instantly share code, notes, and snippets.

@selman
Created July 8, 2010 15:36
Show Gist options
  • Save selman/468159 to your computer and use it in GitHub Desktop.
Save selman/468159 to your computer and use it in GitHub Desktop.
[slmn@azrael cbtohtml]$ time ./cbtohtml.rb &>/dev/null
real 0m0.726s
user 0m0.313s
sys 0m0.043s
#!/usr/bin/env ruby
require 'rubygems'
require 'syntax/convertors/html'
if ARGV.size == 0 then
require 'Qt4'
app = Qt::Application.new []
clipboard = Qt::Application.clipboard
@code = clipboard.text
elsif ARGV.size == 1
@code = File.read(ARGV[0])
else
puts "without argument converts clipboard content\nUsage:\n"
puts "cbtohtml.rb [filename.rb]\ncbtohtml.rb [filename.rb] > output.html\n"
exit
end
convertor = Syntax::Convertors::HTML.for_syntax "ruby"
puts convertor.convert(@code)
[slmn@azrael cbtohtml]$ time ./cbtohtml.rb cbtohtml.rb &>/dev/null
real 0m0.189s
user 0m0.133s
sys 0m0.023s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment