From: ara.t.howard@... Date: 2006-08-10T23:16:58+09:00 Subject: Re: Pretty-printing Ruby code to HTML On Thu, 10 Aug 2006, Tomasz Wegrzanowski wrote: > Hello, > > I need to pretty print some Ruby code into HTML. > Any pointers :-) ? > > -- > Tomasz Wegrzanowski [ http://t-a-w.blogspot.com/ ] this ruby script uses vim to syntax highlight __any__ source code (fortran, ocaml, idl, etc) to html: #!/usr/bin/env ruby require 'tempfile' $VERBOSE=nil STDERR.reopen(Tempfile::new($$)) unless STDIN.tty? fin = ARGV.shift fout = ARGV.shift fin = ((fin.nil? or fin == '-') ? STDIN : open(fin)) fout = ((fout.nil? or fout == '-') ? STDOUT : open(fout,'w+')) ts = Tempfile::new($$), Tempfile::new($$) ts[0].write fin.read ts.each{|t| t.close} command = %Q( vim -f +'syn on' +'set filetype=ruby' +'set background=light' +'run! syntax/2html.vim' +'w! #{ ts[1].path }' +'qa!' - < #{ ts[0].path } > /dev/null 2>&1 ) system command ts.each{|t| t.open; t.rewind} fout.write(ts[1].read) ts.each{|t| t.close!} -a -- to foster inner awareness, introspection, and reasoning is more efficient than meditation and prayer. - h.h. the 14th dali lama