Friday, June 13, 2008

using code examples in blogger.com

Including code snippets is always a mess in blogger; here's what I've found by trial and error:

  • Encode things with an HTML encoder such as this one. There's really no easy way to just paste what you want without this kind of preprocessing.


  • I prefer to use <pre> for formatting because it won't wrap:


like this example that preserves display but goes off the end of our narrow little page very quickly


  • Use <code> if you don't care that it wraps:


so here we have an example with the monospaced font, but it wraps to the next line as it gets to the end


  • The <blockquote> will give you indentation, but usually that pushes you off the screen, so I wouldn't use it:




like this example that quickly spirals out of control and out of the short bounds we have in this thing....



  • Don't even try to use <xmp> tags; they will get processed into mush when you jump back-and-forth from from 'Edit Html'.


such as this example using the &amp;amp;amp;amp;amp;amp;amp;amp;lt;xmp&amp;amp;amp;amp;amp;amp;amp;amp;gt; tag

No comments: