Thursday, November 12, 2009

Displaying Ruby code on a blog

I spent a bit of time trying to figure out the best way to display Ruby code on this blog. Initially I just converted the code to Courier font but it looked ugly and was hard to work with.

I eventually found this link on Stack Overflow:

http://stackoverflow.com/questions/1644201/how-can-i-display-code-better-on-my-blogger-blog

There were a few other methods I found, such as this strategy to convert the code via a Ruby script to HTML and then put it in the clipboard. But I liked the Stack Overflow method the best because all I need to do is add these HTML tags to the code:

<pre class="brush: ruby" name="code">
(Code)
<pre>

Here's an example of what it looks like:

Class Foo
  def bar
  end
end

And here is how to widen the main text column so the code doesn't constantly get wrapped:

http://johndeeremom.blogspot.com/2008/07/how-to-widen-your-columns-on-blogger.html

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home