Pretty-printing Ruby code to HTML

Discussion in 'Ruby' started by Tomasz Wegrzanowski, Aug 10, 2006.

  1. Tomasz Wegrzanowski, Aug 10, 2006
    #1
    1. Advertising

  2. On 8/10/06, Tomasz Wegrzanowski <> wrote:
    > Hello,
    >
    > I need to pretty print some Ruby code into HTML.
    > Any pointers :) ?


    Load it up in vim and export as html :)TOhtml)

    martin
     
    Martin DeMello, Aug 10, 2006
    #2
    1. Advertising

  3. On 10/08/06, Tomasz Wegrzanowski <> wrote:
    > Hello,
    >
    > I need to pretty print some Ruby code into HTML.
    > Any pointers :) ?
    >
    > --
    > Tomasz Wegrzanowski [ http://t-a-w.blogspot.com/ ]
    >
    >


    vim can do it quite nicely. Not sure how, but I know it can.

    Farrel
     
    Farrel Lifson, Aug 10, 2006
    #3
  4. Embedded Ruby Question

    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


    --------------------
    Brian E Campbell
     
    Brian Campbell, Aug 10, 2006
    #4
  5. Tomasz Wegrzanowski

    Guest

    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
     
    , Aug 10, 2006
    #5
  6. Tomasz Wegrzanowski, Aug 10, 2006
    #6
  7. Tomasz Wegrzanowski

    tesla Guest

    Tomasz Wegrzanowski wrote:
    > Hello,
    >
    > I need to pretty print some Ruby code into HTML.
    > Any pointers :) ?
    >

    I usually use Jedit and the code2html plugin.
     
    tesla, Sep 10, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig Duffield

    Pretty Printing

    Craig Duffield, Feb 26, 2004, in forum: Java
    Replies:
    0
    Views:
    378
    Craig Duffield
    Feb 26, 2004
  2. Christian Ashby

    Pretty Printing / Code formatting for JSPs

    Christian Ashby, Aug 20, 2004, in forum: Java
    Replies:
    0
    Views:
    379
    Christian Ashby
    Aug 20, 2004
  3. David
    Replies:
    5
    Views:
    330
    bsneddon
    Jul 8, 2007
  4. Ben
    Replies:
    5
    Views:
    213
    Tom Copeland
    Oct 10, 2005
  5. Martin Pirker

    pretty printing Ruby code

    Martin Pirker, Mar 3, 2011, in forum: Ruby
    Replies:
    2
    Views:
    128
    Vicente Bosch Campos
    Mar 21, 2011
Loading...

Share This Page