Welcome to MSDN Blogs Sign in | Join | Help

jaredpar's WebLog

Code, rants and ramblings of a programmer.

Syndication

News

Now Reading

Expert F#

What's a better book to read when learning F#?

Essential WPF

Thus far the best book I've read on WPF. Gets right down to working with WPF and the goals/history.

Purely Functional Data Structures

Reading this book makes me feel like I'm back in college. It will really get your mind going and is best read with a whiteboard handy.

Blog Roll

Eric Lippert
Dustin Campbell
Jon Skeet
Coding Horror
Brian McNamara
Brian Bondy
Hub FS
Full List

Making code display better on your blog

My blogging tool is Windows Live Writer and I use the "Insert From Visual Studio" plug-in to get pretty looking code into my postings.  The generated code uses the <pre> tag for formatting the elements. 

Unfortunately my blog provider doesn't always render this properly and will clip text that is too long.  Ideally I would like to either

  1. Wrap code that overflows the page
  2. Put up a localized scroll bar for the code snippet

Luckily the plug-in puts the outer most <pre> tag into it's own CSS class: code.  This makes the problem easy with a CSS override.

pre.code {
  overflow : auto;
}

Published Thursday, June 19, 2008 8:00 AM by Jared Parsons

Filed under:

Comments

# re: Making code display better on your blog @ Thursday, June 19, 2008 9:03 AM

Unfortunately it looks like crap in my feed reader :(. (Outlook 2007.) Linebreaks don't seem to be happening, for one.

Domenic

# re: Making code display better on your blog @ Thursday, June 19, 2008 11:27 AM

@Domenic,

I verified in outlook tha this is the case.  I'm not sure what is going on there as the code displays fine in other readers.  Hopefully it's an issue fixed in a newer version of the plugin.  I'm going to look into that over the weekend.

Jared Parsons

# re: Making code display better on your blog @ Thursday, June 19, 2008 11:57 AM

Here's what I do to ensure that it looks good on the web and in the feed -- at least with the readers I've tried (google reader, gator, rss bandit, outlook, etc.).

http://diditwith.net/2007/09/19/HowIFormatCodeForTheWebAndRSSFeeds.aspx

Dustin Campbell

# re: Making code display better on your blog @ Thursday, June 19, 2008 2:15 PM

This blog has been created to share useful information. Thanks and greetings!

world.com.ru

# re: Making code display better on your blog @ Tuesday, July 08, 2008 3:38 PM

I've been putting the code in a scrollable container.

Koush

New Comments to this post are disabled
Page view tracker