Register | Login

Stacking Code

public interface IBlog { string Dump(Stream consciousness); }

Prettify and Internet Explorer

Monday, 20 December, 2010 @ 9:03 PM < Adam Boddington
Tags: Building Neno, CSS, jQuery, Prettify

This is post #29 in the Building Neno series. Please click here for a description of the Building Neno project and instructions on how to access the source code for this post.

I don't use Internet Explorer at home or work if I can help it. Even intranet developers on the Microsoft stack have to struggle with CSS occasionally, so the small amount of goodwill I had towards this stalwart of earlier years disappeared long ago.

That said, IE is still the standard browser at work. That means I have to fire it up every now and then to make sure my applications render nicely. Doing that today I realised I hadn't checked http://stackingcode.com/ with IE at all yet. So I brought it up, and much to my surprise, it rendered great, thanks to Blueprint.

Scrolling down however, I found the Prettify syntax highlighting did not render correctly...

Missing Line Breaks

The line breaks are failing in IE8 and IE7. My default browser, Firefox, works just fine of course, and so does iPad Safari. I don't use IE, nor do I think anyone else should either, but it is a common browser and as such can't be completely ignored (yet). So back at home I dedicated some time to fixing it.

The short of it is, my implementation of Prettify marks my <pre><code> blocks like this...

$('pre code').addClass('prettyprint');

After googling, stepping through JavaScript, and finally looking at some sites that use Prettify without any problem in IE, I realised the class attribute was going on the wrong tag. I was putting it on the code tag while other sites were putting it on the pre tag. The fix is as simple as...

$('pre code').parent().addClass('prettyprint');

Firefox and Safari don't care of course, but IE does and now it all works as expected. I'd groan, but having to tinker with IE to get something to work has been such a massive timesink over the years, another couple of hours is nothing by comparison.

There are 0 comments.


Comments

Leave a Comment

Please register or login to leave a comment.


Older
Replacing Spring with Ninject

Newer
got pivot?

Older
Replacing Spring with Ninject

Newer
got pivot?

browse with Pivot


About


Projects

Building Neno


RSS
Recent Posts

Codility Nitrogenium Challenge
OS X Lock
HACT '13
Codility Challenges
Priority Queue


Tags

Architecture (13)
ASP.NET (2)
ASP.NET MVC (13)
Brisbane Flood (1)
Building Neno (38)
C# (4)
Challenges (3)
Collections (1)
Communicator (1)
Concurrency Control (2)
Configuration (1)
CSS (5)
DataAnnotations (2)
Database (1)
DotNetOpenAuth (2)
Entity Framework (1)
FluentNHibernate (2)
Inversion of Control (5)
JavaScript (1)
jQuery (4)
Kata (2)
Linq (7)
Markdown (4)
Mercurial (5)
NHibernate (20)
Ninject (2)
OpenID (3)
OS X (1)
Pivot (6)
PowerShell (8)
Prettify (2)
RSS (1)
Spring (3)
SQL Server (5)
T-SQL (2)
Validation (2)
Vim (1)
Visual Studio (2)
Windows Forms (3)
Windows Service (1)


Archives


Powered by Neno, ASP.NET MVC, NHibernate, and small furry mammals. Copyright 2010 - 2011 Adam Boddington.
Version 1.0 Alpha (d9e7e4b68c07), Build Date Sunday, 30 January, 2011 @ 11:37 AM