How to export highlighted syntax from IRB

  • Thread starter Jason Lillywhite
  • Start date
J

Jason Lillywhite

If you look at the Ruby In Twenty Minutes page here
http://www.ruby-lang.org/en/documentation/quickstart/ 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!
 
J

Jason Lillywhite

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
 
Q

Quintus

Am 04.01.2011 19:15, schrieb Jason Lillywhite:
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
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top