I use TextMate for my Ruby editing, but when printing files, the code isn't syntax highlighted. Are there any good programs for printing out well-formatted color-highlighted Ruby code?
The syntax gem is pretty awesome.
http://www.hokstad.com/syntax-highlighting-in-ruby.html
require 'hpricot'
require 'syntax/convertors/html'
def filter_content(content)
h = Hpricot(content)
c = Syntax::Convertors::HTML.for_syntax "ruby"
h.search('//pre[@class="ruby"]') do |e|
e.inner_html = c.convert(e.inner_text,false)
end
h.to_s
end
Edit: Oh, you are referring to printing... Well you could do convert it to HTML and then print it from your browser I suppose. But I have to wonder why you would print out pages of code?
I don't know if it's relevant in Mac-world, but the SciTE editor that's bundled with the one-click installer for Windows prints nicely in colour on our HP Laserjet. I haven't tried printing from any of the various IDEs - I ought to try it.
I'd probably use Ultraviolet to create an HTML file that's syntax-highlighted to print out...
A good solution which I use is to print from TextMate via vim
which gives you a syntax-highlighted and line-numbered result (or however you choose to configure it.) In addition to vim
it requires ps2pdf
but these are easy to install with macports
etc.
The only limitation is that the file needs to be saved first.
See this page which shows how to set up the macro as a TextMate 'command':
http://biztos.blogspot.com/2008/06/printing-with-textmate-vim-and-friends.html