# Colored syntax output

**URL:** <https://www.ruby-forum.com/t/colored-syntax-output/63042>\
**Category:** Ruby\
**Created:** [June 10, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/colored-syntax-output/63042 "2006-06-10T23:51:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [June 10, 2006, 11:51pm UTC](https://www.ruby-forum.com/t/colored-syntax-output/63042/1 "2006-06-10T23:51:28Z")

</div>

Hello!

Maybe someone here knows how to do this:

I have some Ruby code, and I need it in a syntax colored HTML output  
format.

Is there any easy way to do this, maybe the “ruby” binary can do this?

Thanks alot,  
Rob

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [June 11, 2006, 12:18am UTC](https://www.ruby-forum.com/t/colored-syntax-output/63042/2 "2006-06-11T00:18:52Z")

</div>

On Jun 10, 2006, at 2:48 PM, Robert MannI wrote:

> Hello!
> 
> Maybe someone here knows how to do this:
> 
> I have some Ruby code, and I need it in a syntax colored HTML  
> output format.
> 
> Is there any easy way to do this, maybe the “ruby” binary can do this?

enscript --color --language=html -Eruby --output=blah.html blah.rb

you may need to add knowledge of ruby syntax to the appropriate  
enscript file. i remember this involved finding the ruby-related  
stuff with google and pasting it into a file. you may also need to  
install enscript. i didn’t. i’m on OS X.

– Elliot T.

> **[Curiosity Blog – Elliot Temple](https://www.curi.us/blog/)**
>
> A philosophy blog

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [June 11, 2006, 12:28am UTC](https://www.ruby-forum.com/t/colored-syntax-output/63042/3 "2006-06-11T00:28:27Z")

</div>

On 10-Jun-06, at 5:48 PM, Robert MannI wrote:

> Hello!
> 
> Maybe someone here knows how to do this:
> 
> I have some Ruby code, and I need it in a syntax colored HTML  
> output format.
> 
> Is there any easy way to do this, maybe the “ruby” binary can do this?

If you have vim then this:

vim -f +“syn on” +“run! syntax/2html.vim” +“wq” +“q” file.rb

should generate file.rb.html

Hope this helps,

Mike

–

Mike S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.stok.ca/~mike/](http://www.stok.ca/~mike/)

The “`Stok’ disclaimers” apply.

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [June 11, 2006, 12:34am UTC](https://www.ruby-forum.com/t/colored-syntax-output/63042/4 "2006-06-11T00:34:54Z")

</div>

On Jun 10, 2006, at 2:48 PM, Robert MannI wrote:

> Thanks alot,  
> Rob

Hey Robert-

```
There are two gems that are available that will produce colorized

```

html out of ruby code.

[http://coderay.rubychan.de/](http://coderay.rubychan.de/)  
gem install coderay

AND

[http://syntax.rubyforge.org/](http://syntax.rubyforge.org/)  
gem install syntax

Cheers-  
-Ezra

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [June 11, 2006, 11:33am UTC](https://www.ruby-forum.com/t/colored-syntax-output/63042/5 "2006-06-11T11:33:17Z")

</div>

Thanks alot for all the tips 🙂

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [June 11, 2006, 9:28am UTC](https://www.ruby-forum.com/t/colored-syntax-output/63042/6 "2006-06-11T09:28:31Z")

</div>

I have a blog entry on how I did this…

[http://blog.wolfman.com/articles/2006/05/26/howto-format-ruby-code-for-blogs](http://blog.wolfman.com/articles/2006/05/26/howto-format-ruby-code-for-blogs)

---

<div class="post-metadata">

**Author:** ![Robert\_MannI](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ac91a4/32.png) [@Robert\_MannI](https://www.ruby-forum.com/u/Robert_MannI)\
**Post date:** [June 11, 2006, 8:03pm UTC](https://www.ruby-forum.com/t/colored-syntax-output/63042/7 "2006-06-11T20:03:41Z")

</div>

Robert MannI wrote:

> Hello!
> 
> Maybe someone here knows how to do this:
> 
> I have some Ruby code, and I need it in a syntax colored HTML output  
> format.

SciTE is able to export the current file into RTF, HTML, XML and some  
others.

Stefan
