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

4 Comments:

Blogger Vinoth Kumar said...

PLC Training in Chennai | PLC Training Institute in Chennai | PLC Training Center in Chennai | PLC SCADA Training in Chennai | PLC SCADA DCS Training in Chennai | Best PLC Training in Chennai | Best PLC Training Institute in Chennai | PLC Training Centre in Chennai | Embedded System Training in Chennai | Embedded Training in Chennai | VLSI Training in Chennai | VLSI Training Institute in Chennai

June 15, 2018 at 2:14 AM  
Blogger Vinoth Kumar said...

PLC Training in Chennai | PLC Training Institute in Chennai | PLC Training Center in Chennai | PLC SCADA Training in Chennai | PLC SCADA DCS Training in Chennai | Best PLC Training in Chennai | Best PLC Training Institute in Chennai | PLC Training Centre in Chennai | PLC SCADA Training in Chennai | Automation Training Institute in Chennai | PLC Training in Kerala

June 15, 2018 at 2:14 AM  
Blogger Vinoth Kumar said...

Embedded Training in Chennai | Best Embedded Training in Chennai | Embedded System Training in Chennai | Embedded System Training Institute in Chennai | Best Embedded System Training Institute in Chennai | Embedded Course in Chennai | Embedded System Training Institutes in Chennai | Embedded System Training Center in Chennai | Best Embedded System Training in Chennai | Embedded Systems Training in Chennai | VLSI Training in Chennai | VLSI Training Institute in Chennai

June 15, 2018 at 2:14 AM  
Blogger Vinoth Kumar said...

VLSI Training in Chennai | Best VLSI Training in Chennai | VLSI Training Centres in Chennai | VLSI Courses in Chennai | VLSI Training Courses in Chennai | VLSI Training Institute in Chennai | VLSI Training Institutes in Chennai | Best VLSI Training Institute in Chennai

June 15, 2018 at 2:15 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home