How to export highlighted syntax from IRB

If you look at the Ruby In Twenty Minutes page here
Ruby in Twenty Minutes you will see they
have some nice formatted html from IRB console. How does one go about
getting that into a word processor such as MS Word? I need this for a
little book I’m writing on Ruby for numerical methods.

I have been successful in getting nicely formatted code from NetBeans
into Word using the print html command. I use the Dark Pastels theme and
it looks great. Now I just need the IRB printouts…

Thank you!

Here is my best solution so far:

Use http://tryruby.org/ to generate the html I need for my document then
paste it right in.

I would have loved to see it the same color theme as that used on
ruby-lang.org but oh well.

Jason

Am 04.01.2011 19:15, schrieb Jason L.:

Here is my best solution so far:

Use http://tryruby.org/ to generate the html I need for my document then
paste it right in.

I would have loved to see it the same color theme as that used on
ruby-lang.org but oh well.

Jason

Your could pass your whole code through CodeRay:


require “coderay”

html = CodeRay.scan(“puts ‘Your Code goes here!’”, :ruby).html(:wrap =>
:div)

puts html

The according CSS stylesheet is outputted by the shell command

$ coderay_stylesheet

CodeRay is available as a gem:

gem install coderay

Vale,
Marvin

This is a nice library. Thank you!