Sunday, December 31, 2006

Including Code Samples in Blogger Posts

To include code samples as nice as mine, do the following. Of course, the following instructions are blogger specific. Also, the code was copied from All about Linux.

Go to your template and select "Edit HTML". Add the following code to the section entitled Posts.
.post pre {
background-color: #efefef;
font-family: 'andale mono','Courier New', Monaco, monospace;
font-size: 1.25em;
padding: 1em 1em;
width: 90%;
border: 2px dotted #ddd;
overflow: auto;
}
Now if you want to include some code in your post, then just do the following.
<pre><code>Include code here.</code></pre>
You will have to replace HTML characters (like <>) with the appropriate decimal codes. There are plenty of sites with character tables.