Search This Blog

Sunday, April 08, 2007

copy paste code into blogger

The difference between pasting some random text and pasting source code is that, it is necessary to preserve the formatting (indentations etc.,) when pasting the source code. If you would like to list some program inside the articles posted via blogger, then you can do the following:
  • Convert all the tabs in the program to spaces. While this step is optional, I suggest this since there would be no unwanted surprises with tabs in the final document. If you are using a good editor such as vim, this takes less than a minute.
  • Go to "Edit Html" tab when editing the post
  • Put your code inside

    <pre class="verbatim" xml:space="preserve">
      ...
    </pre>
    tags. 
  • You can also use

    <pre class="literal-block">
      ...
    </pre>
    tags. 

That's it.

1 comment:

Enchantress said...

I'm glad I learnt something for visiting in here! n btw... thanks for the comment u left on my blog. :)

Followers