21.5.10

Displaying Code and HTML On Blogspot

So the best way I have found to post HTML on blogspot is as follows--since you don't have to install any plugins like greasemonkey and so will probably be the longest lasting way of doing this:
http://blogkori.com/how-to-show-htmljava-codes-in-bloggerblogspot-blog-posts/

It does use a converter called "quick escape" but it looks like it uses pretty standard html entities to escape the html.

However if you just want to post non-HTML code you can just enclose with this:
<div><div><pre style="border: 1px dashed rgb(153, 153, 153); padding: 0px; overflow: auto; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; line-height: 14px; width: 100%;"><code>

Put your code here.

</code></pre></div></div>
Usually when I post code I first use the html converter then enclose it, just because some code has html stuff in it (javascript) and because gives it that grey box that separates my code from my blabber.


NOTE: When you go back and forth from compose to html in blogspot editor your text might loose indentation (this is why I do all my editing in html. The padding option is set "padding: 0px" because otherwise it will sometimes cut off ending characters. For instance when I first posted this you couldn't see the ">" on the end of "<code>", although when you did a CTRL-A in the box and copied, it would still grab that character so the problem the padding can create is only in the display. There used to be a blog that had a converter on it that would enclose your code for you but I can no longer find it.

As a side-note, I learned about how to display HTML on blogspot when I was trying to post this method for displaying code on blogspot. You learn so much stuff from blogging!

No comments: