Pretty-printing Ruby code to HTML

  • Thread starter Tomasz Wegrzanowski
  • Start date
B

Brian Campbell

Hi All,

I want to embed Ruby in my C++ program. My question relates to thread
safety in Ruby. I have an application that is massively threaded. If I
create an instance of the ruby interpreter per thread, will Ruby operate in
a thread safe manner?

Thanks.

-Brian
 
A

ara.t.howard

Hello,

I need to pretty print some Ruby code into HTML.
Any pointers :) ?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top