# Printing ruby code

**URL:** <https://www.ruby-forum.com/t/printing-ruby-code/55005>\
**Category:** Ruby\
**Created:** [March 16, 2006, 4:44am UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005 "2006-03-16T04:44:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zakaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zakaria](https://www.ruby-forum.com/u/Zakaria)\
**Post date:** [March 16, 2006, 4:44am UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005/1 "2006-03-16T04:44:05Z")

</div>

Hi,

What is the best way/tools to printing ruby code to a piece of paper  
with:

1. method index
2. line number
3. syntax highlight  
?.

Regards,

– Zakaria  
removed\_email\_address@domain.invalid Yahoo!: z4k4ri4  
[http://zakaria.is-a-geek.org](http://zakaria.is-a-geek.org)  
[http://pemula.linux.or.id](http://pemula.linux.or.id)  
Mau invite gmail? japri aja.

---

<div class="post-metadata">

**Author:** ![Zakaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zakaria](https://www.ruby-forum.com/u/Zakaria)\
**Post date:** [March 16, 2006, 4:47am UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005/2 "2006-03-16T04:47:10Z")

</div>

On 3/15/06, Zakaria [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> What is the best way/tools to printing ruby code to a piece of paper  
> with:
> 
> 1. method index
> 2. line number
> 3. syntax highlight  
> ?.

I’ve had good luck with a2ps.  
Here’s an a2ps stylesheet for Ruby (which could arguably use some  
enhancement, but is decent enough).  
[http://www.terpnet.nl/ruby.ssh](http://www.terpnet.nl/ruby.ssh)

---

<div class="post-metadata">

**Author:** ![Zakaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zakaria](https://www.ruby-forum.com/u/Zakaria)\
**Post date:** [March 16, 2006, 6:02am UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005/3 "2006-03-16T06:02:51Z")

</div>

On Mar 15, 2006, at 9:41 PM, Zakaria wrote:

> – Zakaria  
> removed\_email\_address@domain.invalid Yahoo!: z4k4ri4  
> [http://zakaria.is-a-geek.org](http://zakaria.is-a-geek.org)  
> [http://pemula.linux.or.id](http://pemula.linux.or.id)  
> Mau invite gmail? japri aja.

This is just off the top of my head, so it may not suit your needs  
but here goes: If you happen to use Vim, you could convert the ruby  
file to an html file with the :TOhtml command, then open the html  
file in a web browser and print it. I’m sure that other text editors  
can do something like this as well.

-Ryan

---

<div class="post-metadata">

**Author:** ![Zakaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zakaria](https://www.ruby-forum.com/u/Zakaria)\
**Post date:** [March 16, 2006, 6:11am UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005/4 "2006-03-16T06:11:54Z")

</div>

> This is just off the top of my head, so it may not suit your needs  
> but here goes: If you happen to use Vim, you could convert the  
> ruby file to an html file with the :TOhtml command, then open the  
> html file in a web browser and print it. I’m sure that other text  
> editors can do something like this as well.

That’s kind of what I was going to recommend. I use a Drupal blog  
with VIM perl modules installed in the blog and on my server to  
syntax color code, ruby included.

- Ken

---

<div class="post-metadata">

**Author:** ![Zakaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zakaria](https://www.ruby-forum.com/u/Zakaria)\
**Post date:** [March 16, 2006, 7:48am UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005/5 "2006-03-16T07:48:51Z")

</div>

I can’t quite help you with your question directly (I just print from  
Textmate – not colour coded), but for those of you looking to print  
code in their Wordpress powered blogs, I’ve been using Code Snippet  
([http://blog.enargi.com/codesnippet/](http://blog.enargi.com/codesnippet/)). Although it doesn’t officially  
support Ruby, if you move Ruby script from the Geshi folder (a required  
dependency) into your Code Snippet directory, you’ll be made in the  
shade.

James H.

---

<div class="post-metadata">

**Author:** ![Zakaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zakaria](https://www.ruby-forum.com/u/Zakaria)\
**Post date:** [March 16, 2006, 5:50am UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005/6 "2006-03-16T05:50:43Z")

</div>

Zakaria wrote:

> Hi,
> 
> What is the best way/tools to printing ruby code to a piece of paper  
> with:
> 
> 1. method index
> 2. line number
> 3. syntax highlight  
> ?.

I don’t know how this compares with the a2ps version, but here’s  
something by Mike Wilson using enscript:

[http://rubyforge.org/cgi-bin/viewcvs.cgi/\*checkout\*/support/ruby.st?rev=1.1](http://rubyforge.org/cgi-bin/viewcvs.cgi/*checkout*/support/ruby.st?rev=1.1)

---

<div class="post-metadata">

**Author:** ![Zakaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zakaria](https://www.ruby-forum.com/u/Zakaria)\
**Post date:** [March 16, 2006, 3:31pm UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005/7 "2006-03-16T15:31:41Z")

</div>

[http://rd.cycnus.de/coderay/](http://rd.cycnus.de/coderay/)  
Take a closer look, i find it useful!

Zakaria schrieb:

---

<div class="post-metadata">

**Author:** ![Zakaria](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b5ac83/32.png) [@Zakaria](https://www.ruby-forum.com/u/Zakaria)\
**Post date:** [March 17, 2006, 6:28pm UTC](https://www.ruby-forum.com/t/printing-ruby-code/55005/8 "2006-03-17T18:28:20Z")

</div>

On 3/15/06, Zakaria [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> – Zakaria  
> removed\_email\_address@domain.invalid Yahoo!: z4k4ri4  
> [http://zakaria.is-a-geek.org](http://zakaria.is-a-geek.org)  
> [http://pemula.linux.or.id](http://pemula.linux.or.id)  
> Mau invite gmail? japri aja.

When stuck in Win32 land you can also check out using the scite editor:

scite -p

Gets you 2 and 3, but no method index.

pth
