:-$

Ryan's work blog

My Links

News

The WeatherPixie
Subscribe with Bloglines
About this blog

Tools I use:

Post Categories

Article Categories

Archives

Image Galleries

Blog Stats

Personal

Projects

Random Blogs

Random other

Reference

Web comics

Work

XUL Description revisited

A long time ago I ranted on the inconvienence using the XUL <description> element with multi-line strings. I received a 3 suggestions in comments, and here's how they fared.
First, the final product:

Daniel's CDATA idea

dwc suggested using CDATA to escape the newlines. Here's the XUL:
<description>
   <![CDATA[
   several
   lines
   at
   once.]]>
</description>
A good thought, but no dice.

ayembee's html idea

Ayembee suggested adding the html namespace to the page, and then using old fashioned line breaks. Here's the XUL:
<description>
   several<html:br/>
   lines<html:br/>
   at<html:br/>
   once.
</description>
This renders acceptably, but putting in <html:br> isn't that much better than making multiple <description> elements. I'm still going to be breaking up the source string (which comes from a SOAP call), splitting on '\n' and adding the node for <html:br>. It works, but I like Karlo's solution better.

Karlos' pre idea

Karlos' suggested using some CSS to treat the contents like a pre block. Here's the XUL:
<description style="white-space: pre;">several
lines
at
once.</description>
This renders nicely, and the only downside is that the XML can't be indented properly, as the style is whitespace sensitive. Fortunately, in my case this isn't really an issue, since the text is being fed from javascript.
Karlos is the big winner, and thank you all for playing "Fix Ryan's horrible, unnecessary hack!"
Update: Using a static syntax highlighter now (GeSHi), so the rss feed won't freak out.

posted on Thursday, March 10, 2005 11:45 AM