# Write ruby code on a blog

**URL:** <https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829>\
**Category:** Ruby\
**Created:** [April 15, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829 "2008-04-15T14:15:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [April 15, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829/1 "2008-04-15T14:15:59Z")

</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:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [April 15, 2008, 6:00pm UTC](https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829/2 "2008-04-15T18:00:58Z")

</div>

On Apr 15, 8:10 am, aidy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [April 15, 2008, 6:14pm UTC](https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829/3 "2008-04-15T18:14:29Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

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

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

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

Greetings  
Florian G.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkgE1BgACgkQJA/zY0IIRZZMQQCfeyjAQ1Nk73RRX+HQQmIv6PSL  
usoAoMvtjPspjndfWps2mPbaa8NkalDA  
=WhB6  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [April 15, 2008, 6:59pm UTC](https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829/4 "2008-04-15T18:59:39Z")

</div>

On Wed, Apr 16, 2008 at 01:00:10AM +0900, Karl von Laudermann wrote:

> 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.

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

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [April 16, 2008, 4:37am UTC](https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829/5 "2008-04-16T04:37:53Z")

</div>

-----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-----

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [April 22, 2008, 4:57pm UTC](https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829/6 "2008-04-22T16:57:12Z")

</div>

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?

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 G. II

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [April 16, 2008, 5:18am UTC](https://www.ruby-forum.com/t/write-ruby-code-on-a-blog/134829/7 "2008-04-16T05:18:13Z")

</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 C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
