1

Possible Duplicate:
How to post source code in Blogger?

I try to blog in blogger.com.

it's ok for text and images, but every time I want to put source code, it's a pain...

Here in stackexchange is so easy to post code!

simply()
{
   works();//Hello I am a source code
} 

But definitely blogs platforms aren't (still) ready ​​for source code.

Does anyone know a sane way of of blogging formatted text + source code ?

PD: meta feature request... stackexchange blogs!!

8

The most basic form is just wrap your code with <code> tags. If you want somthing more fancy, you can use http://codeformatter.blogspot.com/. Just paste in your code beforehand and it will give you the HTML to paste on your Blogger page. It gives nice effects like alternating color lines and line numbers.

For example your example, using the defaults becomes

<pre style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;">
<code style="color:#000000;word-wrap:normal;">

simply()  
{  
    works(); //Hello I am a source code
}

</code>
</pre>
2

If you want to have similar result as in StackExchange sites, use Google Prettify. This is exactly what is used here.

1

You haven't actually told us what is painful.

Is it the lack of shading? Or is it the fact that Blogger tries to interpret HTML (and HTML-like) commands in the code.

If it's the latter, then a very simpley solution is just to turn of the interpretation: it's an option under the Post Options settings in the post-editor.

Not the answer you're looking for? Browse other questions tagged or ask your own question.