XML/HTML display code for Ruby

Discussion in 'Ruby' started by Charles Comstock, Feb 11, 2004.

  1. Alright so I know that RDoc does syntax highlighting on ruby code if you
    view each code block, and I know that you can use the top frames to
    switch around between files, but has anyone written a pretty print ruby
    to html converter that does nice things like link all the in project
    functions? That way if you call a function inside one method it will
    jump you to that method, or if you require a library it will jump you to
    that library, etc? This would be kind of nice in RDoc, but mostly it
    would be nice for a good way to read code others have written. I know I
    have seen similar stuff used on say the C code for the linux kernel, but
    it would be a nice way to peruse code in say rubyforge or RAA.

    On another, similar note, what pretty print to printer packages exist
    that do syntax highlighting of ruby? I gather enscript should have a
    module for it, not quite sure how to use that, I'm used to using a2ps,
    and haven't notice a highlighter for that thus far. Suggestions?

    Charles Comstock
    Charles Comstock, Feb 11, 2004
    #1
    1. Advertising

  2. On Wed, 11 Feb 2004 16:03:37 -0600, Charles Comstock wrote:

    > Alright so I know that RDoc does syntax highlighting on ruby code if you
    > view each code block, and I know that you can use the top frames to
    > switch around between files, but has anyone written a pretty print ruby
    > to html converter that does nice things like link all the in project
    > functions? That way if you call a function inside one method it will
    > jump you to that method, or if you require a library it will jump you to
    > that library, etc? This would be kind of nice in RDoc, but mostly it
    > would be nice for a good way to read code others have written. I know I
    > have seen similar stuff used on say the C code for the linux kernel, but
    > it would be a nice way to peruse code in say rubyforge or RAA.
    >
    > On another, similar note, what pretty print to printer packages exist
    > that do syntax highlighting of ruby? I gather enscript should have a
    > module for it, not quite sure how to use that, I'm used to using a2ps,
    > and haven't notice a highlighter for that thus far. Suggestions?


    IIRC enscript cannot (yet) color Ruby code.. thats what rubyforge is using
    in viewcvs. However VIM can hilight Ruby code.. and maybe be used in
    conjunction with a2ps?

    BTW: It would be really nice with a syntax hiliter that could understand
    the HEREDOC sections in Ruby code. For instance a "EOHTML" heredoc, could be
    interpreted as HTML. Similar with EOXML, EORUBY, EOTEXT.

    Long time out in the future I plan to make a syntax hiliter myself for
    AEditor.. but first I must finish my regexp-engine subproject.

    --
    Simon Strandgaard
    Simon Strandgaard, Feb 11, 2004
    #2
    1. Advertising

  3. On Wed, 11 Feb 2004 23:14:00 +0100, Simon Strandgaard wrote:
    > On Wed, 11 Feb 2004 16:03:37 -0600, Charles Comstock wrote:

    [snip]
    >> On another, similar note, what pretty print to printer packages exist
    >> that do syntax highlighting of ruby? I gather enscript should have a
    >> module for it, not quite sure how to use that, I'm used to using a2ps,
    >> and haven't notice a highlighter for that thus far. Suggestions?

    >
    > IIRC enscript cannot (yet) color Ruby code.. thats what rubyforge is using
    > in viewcvs. However VIM can hilight Ruby code.. and maybe be used in
    > conjunction with a2ps?

    [snip]

    If you have VIM you can convert your ruby file to html.
    vim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" filename.rb
    And it produces a 'filename.rb.html' file as output.

    --
    Simon Strandgaard
    Simon Strandgaard, Feb 12, 2004
    #3
  4. Charles Comstock

    Paul Brannan Guest

    On Thu, Feb 12, 2004 at 10:14:57PM +0900, Simon Strandgaard wrote:
    > If you have VIM you can convert your ruby file to html.
    > vim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" filename.rb
    > And it produces a 'filename.rb.html' file as output.


    Seems like it would be easier to use code2html:
    http://www.palfrader.org/code2html/

    Paul
    Paul Brannan, Feb 12, 2004
    #4
  5. Charles Comstock

    Jim Weirich Guest

    Paul Brannan said:
    > On Thu, Feb 12, 2004 at 10:14:57PM +0900, Simon Strandgaard wrote:
    >> If you have VIM you can convert your ruby file to html.
    >> vim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" filename.rb
    >> And it produces a 'filename.rb.html' file as output.

    >
    > Seems like it would be easier to use code2html:
    > http://www.palfrader.org/code2html/


    source2html is also an option ...
    http://onestepback.org/software/source2html

    --
    -- Jim Weirich http://onestepback.org
    -----------------------------------------------------------------
    "Beware of bugs in the above code; I have only proved it correct,
    not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
    Jim Weirich, Feb 12, 2004
    #5
  6. Charles Comstock

    Alan Chen Guest

    Simon Strandgaard <> wrote in message news:<>...
    > BTW: It would be really nice with a syntax hiliter that could understand
    > the HEREDOC sections in Ruby code. For instance a "EOHTML" heredoc, could be
    > interpreted as HTML. Similar with EOXML, EORUBY, EOTEXT.


    It isn't a syntax hiliter for display but... Emacs has the mmm-mode
    project which turns on different major modes within the same buffer
    based upon start-end region regexps.
    Alan Chen, Feb 12, 2004
    #6
  7. Simon Strandgaard wrote:
    > On Wed, 11 Feb 2004 16:03:37 -0600, Charles Comstock wrote:
    >
    >
    >>Alright so I know that RDoc does syntax highlighting on ruby code if you
    >>view each code block, and I know that you can use the top frames to
    >>switch around between files, but has anyone written a pretty print ruby
    >>to html converter that does nice things like link all the in project
    >>functions? That way if you call a function inside one method it will
    >>jump you to that method, or if you require a library it will jump you to
    >>that library, etc? This would be kind of nice in RDoc, but mostly it
    >>would be nice for a good way to read code others have written. I know I
    >>have seen similar stuff used on say the C code for the linux kernel, but
    >> it would be a nice way to peruse code in say rubyforge or RAA.
    >>
    >>On another, similar note, what pretty print to printer packages exist
    >>that do syntax highlighting of ruby? I gather enscript should have a
    >>module for it, not quite sure how to use that, I'm used to using a2ps,
    >>and haven't notice a highlighter for that thus far. Suggestions?

    >
    >
    > IIRC enscript cannot (yet) color Ruby code.. thats what rubyforge is using
    > in viewcvs. However VIM can hilight Ruby code.. and maybe be used in
    > conjunction with a2ps?
    >
    > BTW: It would be really nice with a syntax hiliter that could understand
    > the HEREDOC sections in Ruby code. For instance a "EOHTML" heredoc, could be
    > interpreted as HTML. Similar with EOXML, EORUBY, EOTEXT.
    >
    > Long time out in the future I plan to make a syntax hiliter myself for
    > AEditor.. but first I must finish my regexp-engine subproject.
    >
    > --
    > Simon Strandgaard
    >
    >


    I'm not exactly familiar with the syntax for highlighting in a2ps, but I
    don't think you could use the vim hilighting in conjunction with it. If
    vim marked up the code it would be more likely that a2ps would try to
    print these additional control codes then use them as highlighting
    suggestions. That's my experience with a2ps anyway.

    Charles Comstock
    Charles Comstock, Feb 12, 2004
    #7
  8. What I do is to convert my ruby(or any) scripts into html using vim,
    --------------
    ARGV.each do |f|
    `vim -f +"syn on" +"colorscheme elflord" +"set number" +"run! syntax/2html.vim" +"wq" +"q" #{f}`
    end
    --------------
    then I print the html through any browser capable to print in color.
    so I think vim could help ...

    -ronnie



    >>>
    >>>
    >>> On another, similar note, what pretty print to printer packages
    >>> exist that do syntax highlighting of ruby? I gather enscript should
    >>> have a module for it, not quite sure how to use that, I'm used to
    >>> using a2ps, and haven't notice a highlighter for that thus far.
    >>> Suggestions?

    >>
    >>
    >>
    >>

    >
    > I'm not exactly familiar with the syntax for highlighting in a2ps, but
    > I don't think you could use the vim hilighting in conjunction with
    > it. If vim marked up the code it would be more likely that a2ps
    > would try to print these additional control codes then use them as
    > highlighting suggestions. That's my experience with a2ps anyway.
    >
    > Charles Comstock
    Bermejo, Rodrigo, Feb 12, 2004
    #8
  9. Charles Comstock

    Tim Hunter Guest

    On Thu, 12 Feb 2004 23:15:06 +0900, Jim Weirich wrote:

    >
    > Paul Brannan said:
    >> On Thu, Feb 12, 2004 at 10:14:57PM +0900, Simon Strandgaard wrote:
    >>> If you have VIM you can convert your ruby file to html.
    >>> vim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" filename.rb
    >>> And it produces a 'filename.rb.html' file as output.

    >>
    >> Seems like it would be easier to use code2html:
    >> http://www.palfrader.org/code2html/

    >
    > source2html is also an option ...
    > http://onestepback.org/software/source2html


    source-highlight also has support for Ruby and can produce XHTML:
    http://www.gnu.org/software/src-highlite/source-highlight.html
    Tim Hunter, Feb 13, 2004
    #9
    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 Kenisston

    HTML code warnings in asp.net html code view

    Craig Kenisston, Oct 7, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,066
    Martin Dechev
    Oct 7, 2004
  2. blank101
    Replies:
    2
    Views:
    514
    blank101
    Feb 5, 2005
  3. Marek Kurowski
    Replies:
    1
    Views:
    972
    Mark A. Odell
    Aug 18, 2004
  4. sed_y
    Replies:
    0
    Views:
    953
    sed_y
    Feb 15, 2012
  5. Erik Wasser
    Replies:
    5
    Views:
    414
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page