Created
July 8, 2010 15:36
-
-
Save selman/468159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[slmn@azrael cbtohtml]$ time ./cbtohtml.rb &>/dev/null | |
real 0m0.726s | |
user 0m0.313s | |
sys 0m0.043s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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