Tuesday, August 2, 2011

Pasting code in Blogger

Copying code directly from any IDE like eclipse into Blogger, without loosing the formatting & readability.

I am a developer and own this blog which talks about all programming stuff. When I initially started using blogspot, anything piece of code I pasted got screwed up in formatting. The readability of the code was all drained into gutter. For any programming blogger who blogs about code, it was very frustrating. After a lot of Googling I found one useful tip.

Wrap your code like this --

<blockquote>
<pre>
YOUR CODE GOES HERE
</pre>
</blockquote>

If your code has < > signs, something like List<Object>, then -

Replace less than < sign with &lt;
Replace greater than > sign with &gt;

There are some tools available which convert your code into this format. Try this - http://francois.schnell.free.fr/tools/BloggerPaste/BloggerPaste.html

Note: You get to do paste code with wrapping tags in EditHTML pannel of the Blogger

It helped me. Hope it helps to you too :)


1 comment: