# Write ruby code on a blog

**URL:** <https://rubytalk.org/t/write-ruby-code-on-a-blog/45891>\
**Category:** ruby-talk\
**Created:** [15 April 2008 12:15 UTC](https://rubytalk.org/t/write-ruby-code-on-a-blog/45891 "2008-04-15T12:15:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidy1](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@aidy1](https://rubytalk.org/u/aidy1)\
**Post date:** [15 April 2008 12:15 UTC](https://rubytalk.org/t/write-ruby-code-on-a-blog/45891/1 "2008-04-15T12:15:03Z")

</div>

Hi,

Anyone got any ideas on how to easily write and correctly display  
(with syntax highlighting) Ruby code on a blog?

Regards,

Aidy

---

<div class="post-metadata">

**Author:** ![Karl\_von\_Laudermann](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@Karl\_von\_Laudermann](https://rubytalk.org/u/Karl_von_Laudermann)\
**Post date:** [15 April 2008 16:00 UTC](https://rubytalk.org/t/write-ruby-code-on-a-blog/45891/2 "2008-04-15T16:00:10Z")

</div>

In the past I've done this using Vim. Vim has a command called  
something like TOhtml, which will take the displayed file (such as  
ruby code) and generate an html file that displays the code with the  
same syntax coloring that Vim itself displays the code in. I've done  
this manually by loading the desired file into Vim, executing the  
command, then saving the resulting file to an .html file, but I  
wouldn't be surprised if there's a way to automate it.

> **···**
>
> On Apr 15, 8:10 am, aidy \<aidy.le...@googlemail.com\> wrote:
> 
> > Hi,
> > 
> > Anyone got any ideas on how to easily write and correctly display  
> > (with syntax highlighting) Ruby code on a blog?

---

<div class="post-metadata">

**Author:** ![Florian\_Gilcher](https://avatars.discourse-cdn.com/v4/letter/f/57b2e6/32.png) [@Florian\_Gilcher](https://rubytalk.org/u/Florian_Gilcher)\
**Post date:** [15 April 2008 16:13 UTC](https://rubytalk.org/t/write-ruby-code-on-a-blog/45891/3 "2008-04-15T16:13:30Z")

</div>

You could run it through CodeRay which is a Syntax Highlighter written in Ruby.

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

Greetings  
Florian Gilcher

> **···**
>
> On Apr 15, 2008, at 2:15 PM, aidy wrote:
> 
> > Hi,
> > 
> > Anyone got any ideas on how to easily write and correctly display  
> > (with syntax highlighting) Ruby code on a blog?
> > 
> > Regards,
> > 
> > Aidy

---

<div class="post-metadata">

**Author:** ![Antonio\_Cangiano](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@Antonio\_Cangiano](https://rubytalk.org/u/Antonio_Cangiano)\
**Post date:** [16 April 2008 02:35 UTC](https://rubytalk.org/t/write-ruby-code-on-a-blog/45891/4 "2008-04-16T02:35:10Z")

</div>

aidy wrote:

> Anyone got any ideas on how to easily write and correctly display  
> (with syntax highlighting) Ruby code on a blog?

I personally use Pygments: [http://pygments.org](http://pygments.org)

HTH,  
Antonio  
- --  
[http://antoniocangiano.com](http://antoniocangiano.com) - Zen and the Art of Programming  
[http://stacktrace.it](http://stacktrace.it) - Aperiodico di resistenza informatica  
[http://math-blog.com](http://math-blog.com) - Math Blog: Mathematics is wonderful!

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [22 April 2008 14:56 UTC](https://rubytalk.org/t/write-ruby-code-on-a-blog/45891/5 "2008-04-22T14:56:17Z")

</div>

If you use TextMate as your editor, you can convert your code to syntax highlighted HTML using the "Create HTML From Document" command in the "TextMate" bundle.

James Edward Gray II

> **···**
>
> On Apr 15, 2008, at 7:15 AM, aidy wrote:
> 
> > Anyone got any ideas on how to easily write and correctly display  
> > (with syntax highlighting) Ruby code on a blog?

---

<div class="post-metadata">

**Author:** ![Gregory\_Seidman](https://avatars.discourse-cdn.com/v4/letter/g/eb9ed0/32.png) [@Gregory\_Seidman](https://rubytalk.org/u/Gregory_Seidman)\
**Post date:** [15 April 2008 16:57 UTC](https://rubytalk.org/t/write-ruby-code-on-a-blog/45891/6 "2008-04-15T16:57:50Z")

</div>

I missed the original post, but this is what I use for my blog:

[http://redcorundum.blogspot.com/2006/07/syntax-coloring.html](http://redcorundum.blogspot.com/2006/07/syntax-coloring.html)

--Greg

> **···**
>
> On Wed, Apr 16, 2008 at 01:00:10AM +0900, Karl von Laudermann wrote:
> 
> > On Apr 15, 8:10 am, aidy \<aidy.le...@googlemail.com\> wrote:  
> > \> Hi,  
> > \>  
> > \> Anyone got any ideas on how to easily write and correctly display  
> > \> (with syntax highlighting) Ruby code on a blog?
> > 
> > In the past I've done this using Vim. Vim has a command called  
> > something like TOhtml, which will take the displayed file (such as  
> > ruby code) and generate an html file that displays the code with the  
> > same syntax coloring that Vim itself displays the code in. I've done  
> > this manually by loading the desired file into Vim, executing the  
> > command, then saving the resulting file to an .html file, but I  
> > wouldn't be surprised if there's a way to automate it.

---

<div class="post-metadata">

**Author:** ![Zachary\_Scott1](https://avatars.discourse-cdn.com/v4/letter/z/e47c2d/32.png) [@Zachary\_Scott1](https://rubytalk.org/u/Zachary_Scott1)\
**Post date:** [16 April 2008 03:17 UTC](https://rubytalk.org/t/write-ruby-code-on-a-blog/45891/7 "2008-04-16T03:17:31Z")

</div>

If you're using wordpress check out wp-syntax, it supports a wide variety of  
languages using GeSHI (generic syntax highlighting)

> **[WP-Syntax](https://wordpress.org/plugins/wp-syntax/)**
>
> WP-Syntax provides clean syntax highlighting for embedding source code within pages or posts.

> **[GeSHi - Generic Syntax Highlighter :: Home](http://qbnz.com/highlighter/)**
>
> GeSHi - Generic Syntax Highlighter for php. Highlight many languages, including PHP, CSS, HTML, SQL, Java and C for XHTML compliant output using this easy PHP Class. Every aspect of the highlighting is customisable, from colours and other styles to...

> **···**
>
> On Tue, Apr 15, 2008 at 10:35 PM, Antonio Cangiano \<acangiano@gmail.com\> wrote:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----  
> > Hash: SHA1
> > 
> > aidy wrote:  
> > \> Anyone got any ideas on how to easily write and correctly display  
> > \> (with syntax highlighting) Ruby code on a blog?
> > 
> > I personally use Pygments: [http://pygments.org](http://pygments.org)
> > 
> > HTH,  
> > Antonio  
> > - --  
> > [http://antoniocangiano.com](http://antoniocangiano.com) - Zen and the Art of Programming  
> > [http://stacktrace.it](http://stacktrace.it) - Aperiodico di resistenza informatica  
> > [http://math-blog.com](http://math-blog.com) - Math Blog: Mathematics is wonderful!  
> > -----BEGIN PGP SIGNATURE-----  
> > Version: GnuPG v1.4.8 (Darwin)  
> > Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)
> > 
> > iEYEARECAAYFAkgFZRsACgkQqCqsu0qUj9RuUACgqI0FGuZ19jaN3ckL0ysGwM32  
> > B2UAoMjTzfNL1diZeQ5OKpG4//PjMNkY  
> > =9Jz+  
> > -----END PGP SIGNATURE-----
