XML/HTML display code for Ruby

C

Charles Comstock

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
 
S

Simon Strandgaard

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

Simon Strandgaard

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

Alan Chen

Simon Strandgaard said:
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.
 
C

Charles Comstock

Simon said:
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.

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
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top