Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby Code to HTML

Reply
Thread Tools

Ruby Code to HTML

 
 
James Edward Gray II
Guest
Posts: n/a
 
      09-24-2004
I need to HTMLify some Ruby code. Before I go make some crude
solution, I thought I would ask if there is anything out there along
these lines. Any pointers?

Thanks.

James Edward Gray II



 
Reply With Quote
 
 
 
 
Hal Fulton
Guest
Posts: n/a
 
      09-24-2004
James Edward Gray II wrote:
> I need to HTMLify some Ruby code. Before I go make some crude solution,
> I thought I would ask if there is anything out there along these lines.
> Any pointers?


I seem to remember a tool like that. Would be in RAA if so.

Also, I think vim can do that.


Hal




 
Reply With Quote
 
 
 
 
Markus
Guest
Posts: n/a
 
      09-24-2004
Depends. What are you trying to accomplish? I have something that
takes ruby with special comments and makes a cross reference
(hyperlinked) between it and a specification document. But it doesn't
really "read" the ruby code, or format it--it just spits it out <CODE>
with <A>'s interpolated based on the comments.

I briefly thought about linking methods calls to their definitions,
etc., but with duck typing that is...almost intractable. The best I
came up with was a sort of method search that sort of worked, but didn't
find dynamically defined methods, etc.

-- Markus


On Fri, 2004-09-24 at 10:00, James Edward Gray II wrote:
> I need to HTMLify some Ruby code. Before I go make some crude
> solution, I thought I would ask if there is anything out there along
> these lines. Any pointers?
>
> Thanks.
>
> James Edward Gray II
>




 
Reply With Quote
 
Thomas Adam
Guest
Posts: n/a
 
      09-24-2004
--- Hal Fulton <> wrote:
> James Edward Gray II wrote:
> > I need to HTMLify some Ruby code. Before I go make some crude

> solution,
> > I thought I would ask if there is anything out there along these

> lines.
> > Any pointers?

>
> I seem to remember a tool like that. Would be in RAA if so.
>
> Also, I think vim can do that.
>
>
> Hal
>
>
>
>


=====
"The Linux Weekend Mechanic" -- http://linuxgazette.net
"TAG Editor" -- http://linuxgazette.net

"<shrug> We'll just save up your sins, Thomas, and punish
you for all of them at once when you get better. The
experience will probably kill you. "

-- Benjamin A. Okopnik (Linux Gazette Technical Editor)





__________________________________________________ _________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com


 
Reply With Quote
 
Jamis Buck
Guest
Posts: n/a
 
      09-24-2004
James Edward Gray II wrote:
> I need to HTMLify some Ruby code. Before I go make some crude solution,
> I thought I would ask if there is anything out there along these lines.
> Any pointers?
>
> Thanks.
>
> James Edward Gray II


Vim. If you use Vim, you can do

:runtime! syntax/2html.vim

It'll create a new window with your Vim file converted to HTML.

--
Jamis Buck

http://www.jamisbuck.org/jamis

"I use octal until I get to 8, and then I switch to decimal."


 
Reply With Quote
 
Zach Dennis
Guest
Posts: n/a
 
      09-24-2004
A quick and dirty way might be:

#!/usr/bin/ruby

input = File.open( "file.rb" , "r" )
output = File.new( "file.html" , "w+" )

input.each_byte{ |c|
case c.chr!
when "\n"
output.write( "<br>\n" )
when "\s"
output.write( "&nbsp;" )
when "\t"
output.write( 4.times{ "nbsp;" } )
else
output.write( c )
end }


Zach


 
Reply With Quote
 
Mikael Brockman
Guest
Posts: n/a
 
      09-24-2004
James Edward Gray II <> writes:

> I need to HTMLify some Ruby code. Before I go make some crude
> solution, I thought I would ask if there is anything out there along
> these lines. Any pointers?


There's an Emacs package called htmlize. If you want to htmlize every
Ruby file in a certain directory, open the directory with C-x d, hit %
m, give it a regular expression like .rb$, and do M-x
htmlize-many-files-dired. It will write one .html file for every .rb
file.

Here's htmlize: http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el



 
Reply With Quote
 
Tom Copeland
Guest
Posts: n/a
 
      09-24-2004
On Fri, 2004-09-24 at 13:00, James Edward Gray II wrote:
> I need to HTMLify some Ruby code. Before I go make some crude
> solution, I thought I would ask if there is anything out there along
> these lines. Any pointers?


RubyForge's ViewCVS setup uses enscript to do markup. Here's an
example:

http://qurl.net/4M

The enscript colorizer file is here:

http://qurl.net/4N

Yours,

Tom



 
Reply With Quote
 
Kurt Williams
Guest
Posts: n/a
 
      09-24-2004
There's a utility called rb2html that works well.

http://raa.ruby-lang.org/search.rhtml?search=rb2html



On Sat, 25 Sep 2004, James Edward Gray II wrote:

> I need to HTMLify some Ruby code. Before I go make some crude
> solution, I thought I would ask if there is anything out there along
> these lines. Any pointers?
>
> Thanks.
>
> James Edward Gray II
>
>


--
Kurt Williams
Senior Engineer
http://www.nationalgeographic.com




 
Reply With Quote
 
Zach Dennis
Guest
Posts: n/a
 
      09-24-2004
A better version might be:
--------------------------------------------------------------

input = File.open("baselayout_test.rb")
output = File.new( "baselayout_test.html" , "w+" )

input.each_byte{ |c|
c=c.chr
c.gsub!(/\n/ , "<br>\n" ) and output.write( c ) and next if( c=~/\n/ )
c.gsub!(/\s/ , "&nbsp;" ) and output.write( c ) and next if( c=~/\s/ )
c.gsub!(/\t/ , "&nbsp;&nbsp;&nbsp;&nbsp;" ) and output.write( c )
and next if( c=~/\t/ )
output.write( c ) }



Zach Dennis wrote:

> A quick and dirty way might be:
>
> #!/usr/bin/ruby
>
> input = File.open( "file.rb" , "r" )
> output = File.new( "file.html" , "w+" )
>
> input.each_byte{ |c|
> case c.chr!
> when "\n"
> output.write( "<br>\n" )
> when "\s"
> output.write( "&nbsp;" )
> when "\t"
> output.write( 4.times{ "nbsp;" } )
> else
> output.write( c )
> end }
>
>
> Zach
>
>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
firefox html, my downloaded html and firebug html different? Adam Akhtar Ruby 9 08-16-2008 07:55 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
Html code cleaner - Powerful HTML Code Compression Tool heren ASP .Net 1 09-14-2005 12:39 PM
How to stop HTML View from messing up HTML code Anders K. Jacobsen [DK] ASP .Net 3 01-22-2005 01:15 AM
HTML code warnings in asp.net html code view Craig Kenisston ASP .Net 3 10-07-2004 04:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57