Friday, June 23, 2006

Code Formatting for Blogs

It has been annoying me for some time that I didn't have properly formatted code in this blog. I could get it to either indent correctly but expand and ruin the page formatting (using <pre>), or line-wrap inappropriately (using <tt>).

Today I did a bit of web searching and found this excellent blog article on how to format ruby code for blogs. While the whole solution is a bit more than I need, inserting the following snippet of CSS into my blog style was just the ticket.

pre {
background-color: #f1f1f3;
color: #112;
padding: 10px;
font-size: 1.1em;
overflow: auto;
margin: 4px 0px;
width: 95%;
}


There's still a little bit that's not prefect (small <pre>...</pre> sections still look a bit funny), it's almost exactly what I was looking for!

Isn't the web wonderful :-)

No comments: