Wednesday, January 6, 2010

How to show code and not have Blogger interpret it

I had issues with my previous blog and getting both the HTML and the code behind to show correctly (and nicely).

I was able to get the code behind to come out nice and color coded by downloading and using Copy Source As HTML

That covered the code behind, but was not helpful for the HTML. After a bit of research I found that if I use character entities, I am able to display my code (although it is not color coded).

Example: The code used to make this statement bold
is:

<b>The code used to make this statement bold is </b>

To do this, you will need this table converter of the most common conversions:


So, everywhere there is a Less Than symbol, you need to replace it with its equivalent entity name. You can find a complete listing of entity names at the w3schools web page.

You can do a find and replace in Notepad, or you can paste your code into This Web Page and it will convert it all for you. There is a slight usage disclaimer on the bottom of the page, but I read that after I used it.

No comments:

Post a Comment