blog comments edit

Every once in a while I’ll be reading a blog entry and I’ll come across a place where someone has inserted a block of code. On the blog site, it looks like this:

Formatted code on a web
site.

But in the RSS reader, it looks like this:

Formatting displayed incorrectly for code in an RSS
feed.

Not so great. I mean, the code is reasonably legible, but the style sheet renders literally in the reader. I shouldn’t see that CSS - it should be formatting the code, not appearing in the view window.

I also see RSS feeds that do display a nicely formatted block of code:

Code displaying correctly in
RSS.

At first I thought it was a bug in my reader, so I tried some other readers and got the same result.

So what’s the difference?

The one that appears with the styles displayed literally in the feed uses an inline style sheet to do the formatting. Something like this: <pre class="csharpcode"> virtual BOOL Paint(int button) = 0; </pre>

While that sort of thing works well on a web site, it turns out that most RSS readers today don’t support inline style sheets.

The ones that look correct on the web site and in RSS use code like this: <pre style="background-color:#FFFFB9;;overflow: auto;"><div>@Test public void emptyTest() { assertTrue(foo); }</div></pre>

Notice how the styles applied are actually inline on the tags, not styles from a style sheet. This sort of local style application is fairly widely supported in RSS readers. The drawback to this sort of style application is that not only is the HTML huge and horrible (usually it’s generated, and we all know how bad generated HTML gets), but if you want to change the look of the code on your site or in your RSS feed, there’s no simple way to do it.

Two recommendations for folks posting inline code snippets who want formatting and a good looking RSS feed:

If you’re going with a style sheet and not inline styles, move the style sheet to somewhere outside the actual entry being syndicated. Include it with a <link rel="stylesheet" type="text/css" href="http://url/to/your.css" /> line in the <head /> section of your site. By pulling it out of the entry proper, folks visiting your site will see the nice formatting, and at the very least the syndicated version will be legible and won’t include a bunch of clutter. On the other hand, it won’t look as pretty in RSS as it does on your site.

If you want people to see nicely formatted code on your site and in RSS, you’ll need to switch to the inline styles applied directly to tags. The Actipro CodeHighlighter control for ASP.NET does this (and there’s a Windows Live Writer plugin that uses it, so you don’t have to set it up on your site if you want to post through Windows Live Writer instead). The GeSHi (Generic Syntax Highlighter) project is a good PHP highlighter that can do either inline styles or use a style sheet. Check into a solution for your chosen platform that will let you apply the styles inline directly to tags.

Due to the stupid server down issue I had a bit ago, I got moved to a new server but it seems that not all my settings made it, so anyone who had sent mail to any address at paraesthesia.com wasn’t getting through to me.

I just figured it out, and it’s only been since, oh, February 27, so I’ve only got about 1400 emails to manually filter through and deal with. But I’ve got everything fixed again so it should be working fine. If you sent me something that I should have responded to but didn’t, re-send and I’ll answer. ARGH!

Saturday Jenn and I spent the majority of the day at pyrotechnics training, an annual class put on by Western Display Fireworks. Western is the company we work for on the Fourth of July when we head up to Clatskanie and do the fireworks show. You have to attend a training class within the three years prior to your license expiring, and since our license expire next year, we figured this would be a good opportunity. Always good to refresh yourself on the laws and safety regulations.

LEGO Imperial Star
DestroyerSaturday night on the way back from pyro class we stopped by my parents’ place to visit. Mom picked me up a Lego Imperial Star Destroyer for a song at a sale she found so I got that from her. She also found this cool CSI Facial Reconstruction Kit, so she passed that along. Fun!

Sunday was chore day. We got up reasonably early and I went around the house to all the windows and re-caulked everywhere that the caulking had split due to the house settling. That meant all four corners to most of the windows and many spots along the top of each window, necessitating the removal of the blinds. It was a heck of a job and took close to four hours to hit every window in the place, but I got it done and it’s looking good again. Took a tube and a half of caulk, which is a personal record for maximum caulk use at a given time. Heh.

I had planned on watching The Empire Strikes Back and putting together the Lego Imperial Star Destroyer in the afternoon, but since I had run out of caulk (I only bought one tube), we had to run out to the store and while we were out we ended up getting Dance Dance Revolution Universe for Xbox 360 with a Target gift card we had left over from Christmas…

…which, of course, led to my evening consisting of the finishing up of tasks and an hour and a half of DDR, effectively routing my ability to also watch the movie and play Legos. I will have to commence Star-Wars-ing this evening when I get home.

DDR on Xbox 360 is a welcome addition to our home, though. Jenn and I were just talking about how we don’t go to the gym because we’re lazy and it’s boring, and we realized that the one time we did end up losing weight, we were doing an awful lot of DDR. The problem up until now was that, frankly, I’m a Gamerpoint Whore so not getting achievements while I game became patently unacceptable, regardless of the fact we have like three different DDRs for PS2. Now I can have my cake and eat it, too - DDR on Xbox 360 gives me my DDR fix as well as the ability to get Gamerpoints.

In a similar vein, the purchase of DDR was my impetus to pull the receiver out and rewire things so the Xbox 360 now goes through it, finally giving me digital surround in games and media. (Yes, I now realize what I was missing by not having this hooked up and it makes me want to go back and play all the games I’ve already played because it’s that much better.) It was going to have to happen anyway if I ever get off my butt and make the media server I want to, but having to get back there and futz around with the wiring just wasn’t on the top of my list of fun things to do. As it is, my receiver is at its limit with inputs, so the Xbox 360 is now plugged into the CD player optical-in jack and the CD player has been moved to the last remaining input - the “video auxiliary,” which is on the front of the receiver and only offers a standard RCA stereo-in connection. It means I don’t get the digital clarity when I listen to CDs anymore, but that’s not to big of a deal since I don’t listen to CDs very much. Plus, if it’s killing me that much, I can always listen to them through the DVD player rather than the CD player and I’ll get that digital quality back. What does bug me is that it looks hokey - the wires run from the back of the CD player, down the back of the cabinet, and along the shelf next to the receiver to plug into the front of the thing. Not much I can do about that, but it doesn’t overwhelm me with elegance. It does make me think about what I’m going to want in my next receiver, though, and the number one determining factor is going to be quantity of inputs.

At some point over the course of the weekend I put a nice gouge in the right lens of my glasses. Not really sure how it happened or when, but when I was cleaning them last night, there it was. It’s not in my direct line of sight so it’s not bugging me too bad, but if I look through the bottom half of the lens, there’s a bit of blur because of it. It’s probably time to get new lenses anyway.

personal comments edit

A minor follow-up to my FizzBuzz response - In that post I said:

[T]he answer to questions like “What is the maximum amount of memory any single process on Windows can address?” is “Google.” It’s trivia.

I’m feeling justified, at least in that particular case, by Raymond Chen’s post today:

If you have to ask about various operating system limits, you’re probably doing something wrong.