XML/HTML display code for Ruby

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

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.

···

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?


Simon Strandgaard

[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.

···

On Wed, 11 Feb 2004 23:14:00 +0100, Simon Strandgaard wrote:

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


Simon Strandgaard

Simon Strandgaard neoneye@adslhome.dk wrote in message news:pan.2004.02.11.22.14.00.280299@adslhome.dk

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.

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

Seems like it would be easier to use code2html:
Code2HTML

Paul

···

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.

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

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 jim@weirichhouse.org 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)

source-highlight also has support for Ruby and can produce XHTML:
GNU Source-highlight 3.1.8

···

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:
Code2HTML

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