Page 1 of 1

An XHTML 1.1 blog with Serendipity 1.1 features

Posted: Mon Mar 05, 2007 9:48 pm
by mrael2
We just finished converting our blog, SLV Dweller, from MoveableType 3.33 to Serendipity 1.1. It's a blog about the San Luis Valley of Colorado.

Plus, we went ahead and used XHTML 1.1 (with a little bit of embedded SVG) for the markup language. It was an arduous process to convert over 6,000 entries to XHTML, but I think it's worth the effort for the future.

We're using the proper MIME type of application/xhtml+xml, so this means that Internet Explorer users can't see our site. We didn't want to use content negotiation to send a MIME type of text/html because we didn't want to implement XHTML-to-HTML conversion, and XHTML 1.1 can't be sent as text/html. Also, we wanted just one CSS file for all browsers.

Most of our readers had been using Internet Explorer, but we warned them a couple of months in advance about the switch to XHTML 1.1. We've also given them a mechanism to switch their browser to Firefox or Opera, and dozens of them have been switching. Our site has a link to detailed statistics that show browser usage after about five days of sending the application/xhtml+xml MIME type; we switched over on March 1st.

I had to modify a couple of plug-ins also so that they emitted valid XHTML. Plug-in writers: consider testing your plug-ins on an XHTML 1.1 site that uses a MIME type of application/xhtml+xml.

The only other change I made was to index.php to send the proper MIME type for XHTML 1.1 and to give a special page to Internet Explorer users so they can get something besides the download dialog.

We use static pages minimally, but we use multiple sidebars extensively. Our readers have liked our new design, and only a couple of users have complained that IE no longer works. Our readers are willingly making the switch to Firefox or Opera.

Re: An XHTML 1.1 blog with Serendipity 1.1 features

Posted: Mon Mar 05, 2007 10:55 pm
by garvinhicking

What I absolutely dislike about xhtml+xml content type is that at least the last time I tried in Firefox any validation error will kill to display the blog.

You just have to post a link like "index.php?l1=1&l2=2" to force a "unknown entity &l2" error. I've learned that 99% of all s9y users do not know that '&' is not valid in XHTML and they would need to write "&".

Until the validation of XML dies so hard on user input, it's IMHO useless.

I had to modify a couple of plug-ins also so that they emitted valid XHTML.

I'd be very interested in the required changes. We try to keep all plugins XHTML compatible, and this can usually be done without hurting display in HTML.

BTW; my own personal site ( uses XHTML 1.1 and validates on, despite my content-type header being sent as text/html. It's not fully following the specs, but all browser can at least deal with it. ;)

Of course that's just my personal $0.02, but you asked for that :)

Really enjoy your blog, it's got a very unique design and I love to see what you've done with Serendipity. An awful lot of entries you have there, too. :-)

Best regards,

Posted: Thu Mar 08, 2007 3:30 pm
by mrael2
The "Fix common XHTML errors" plug-in is extremely useful in allowing my non-tech-savvy authors to post links with ampersands in them without getting any errors. I've been impressed with this plug-in as it converts "&" to "&" in seemingly every case where it could create problems otherwise.

Good software like this takes flawed, human input and makes sure it conforms to the rigidity that computers require. I'm hoping that one of the philosophies behind Serendipity is to support a robust technical infrastructure while allowing regular humans to do the authoring.

It would be nice if the "Fix common XHTML errors" plug-in caught XHTML problems in trackbacks. We had a trackback with " " in the title, and that broke a page on our web site as a result. " " is illegal in XHTML (as are other character entity references like "©", "«", and "»".

Weather plug-in has malformed XHTML

Posted: Thu Mar 08, 2007 3:32 pm
by mrael2
One of the plug-in fixes I made was to correct some malformed XHTML. Around line 423 of serendipity_plugin_weather.php, I corrected the code to read as follows:

$content .= '<img src="' . $conditionIcon . '" alt="" /><br />'. $conditions . '<br />';
// FIXXME: Translate the Winddirection
$content .= '<dl><dt>'.PLUGIN_SIDEBAR_WEATHER_DATA_WINDDIRECTION.'</dt><dd><img src="' .
$windDirIcon . '" alt="" /></dd>' .
'<dt>'.$windDir . ' at </dt><dd>' . $weather_data["wind"] . ' ' .$units['wind'] . '</dd>';

<blockquote> in XHTML 1.1

Posted: Thu Mar 08, 2007 3:44 pm
by mrael2
Another thing we noticed when we validated our site against the XHTML 1.1 DTD is that this kind of markup is illegal:

<blockquote>Text goes here</blockquote>

XHTML 1.1 requires a block-level element like <p> or <div> after the <blockquote>:

<blockquote><div>Text goes here</div></blockquote>

Would it be possible to change Serendipity to provide that kind of markup when the "quote" button is clicked on a new entry? The benefit to this legal markup is that CSS can then be used to style opening and closing quotation marks as images (such as we do on SLV Dweller).

Validity may not be so important

Posted: Thu Mar 08, 2007 3:57 pm
by mrael2
Regarding my <blockquote> reply above, it may not actually be very important to focus on VALID markup as much as WELL-FORMED markup. Browsers do not validate markup at all, but they do check for well-formed markup ONLY when using the application/xhtml+xml MIME type.

I want my XHTML to be well-formed, and the only way to be sure of that is to use the application/xhtml+xml MIME type so that the XML parser in my browser is triggered. Serendipity users would be well served to recognize that XHTML is really just XML.

I'm becoming less concerned about whether or not my XHTML is valid -- and I've removed the XHTML 1.1 DTD reference as a result -- because XHTML has extensibility as one of its principles. As new XML vocabularies can be embedded within XHTML (SVG and MathML come to mind), it might become harder and harder to validate any given XHTML document.

Especially since WHATWG is working on extensions to (X)HTML, I can't really validate my well-formed XHTML if I use the <canvas> tag, for example. There are no DTDs to validate an XHTML document with the <canvas> tag, but a web site can still be well-formed and use the <canvas> tag.

Really, I'm just advocating well-formed XHTML, and the application/xhtml+xml MIME type is the way to guarantee that.

Posted: Thu Mar 08, 2007 4:18 pm
by garvinhicking

First off, thanks for the XHTML-Fixup plugin. We gave our best. :)

The problem of recoding "&nbsp;" etc. is that it's hard to find a full list of all entities, and that getting the list via html_trans_table on PHP is hard on the performance. So it's really hard to strip out those "invalid" entities that look like valid entities.

I committed your fix to the weather plugin!

BTW, blockquote is already the default quote button in Serendipity versions, I believe since 1.0 or 1.1.

As to the well-formedness: It's still very easy for users to introduce "not wellformed code". Even though you prefer to have such code show up in the browser as an error, most users see it a bit different: They want to see what they write, no matter what they write. They would say "Fuck serendipity, it's a mess" when the whole page did not render because of an error they made.

And even though we put much work in the xhtmlfixup plugin, we can't ensure that it fixes the many things that users can enter. It's near to impossible for a PHP application within the strict performance boundaries to wade through all user input and try to parse it fior well-formedness. Many PHP applications I know have tried to validate user input, but I've never seen a bulletproof working thing.

Even the W3C has made a step back, they are now moving towards HTML5 / XHTML5, which breaks with the XML-conformace on well-formedness. And guess why: They saw it didn't work out. :-)

User-input is flawed. We need to face that. Even though advanced users might be pedantic about those errors, and they might want to have a perfectly validating content, we cannot do that to normal users. And Serendipity is all about making normal users AND advanced users happy.

Advanced users can emit a xhtml+xml header very easily using a php s9y plugin, or puttin gthe header() call in the index.php or template's file. So advanced users can have that content-type without a real problem.

But we'll not have it as a s9y default, at least not with current implementations and fatal browser bailouts.

Best regards

Posted: Thu Mar 08, 2007 4:35 pm
by mrael2
garvinhicking wrote:Even the W3C has made a step back, they are now moving towards HTML5 / XHTML5, which breaks with the XML-conformace on well-formedness. And guess why: They saw it didn't work out. :-)

You raise some valid points, and XHTML may not have widespread adoption in the short term as a result of what you have pointed out. But I wouldn't say the W3C is taking a step back. Their new HTML working group is about evolving both HTML and XHTML. Well-formedness will remain a bedrock principle of XHTML5 or whatever W3C ends up calling it. From their press release:

The markets for XML content are significant and growing, so W3C will define an XML syntax for the new HTML in addition to the classic HTML syntax.

Posted: Fri Mar 09, 2007 9:40 am
by garvinhicking

The markets for XML content are significant and growing, so W3C will define an XML syntax for the new HTML in addition to the classic HTML syntax.

IMHO exactly that phrase is what makes XML set back: Even though they say they want to support XML, they also talk about CLASSIC HTML.

What good does it to if you have one very loose adaptation and a strict one? Developers or Users will never use XML, if they also have an ugly, easy syntax that chews on everything that they enter?

IMHO offering a new classic syntax means that they step back from XML - in previous plan (and a perfect world) the ugly HTML non-wellformedness would be discontinued as it had been advocated a few years back by the W3C - and now they do continue it.

That's a shame, IMHO. Instead loosening up the strictness of XML would be the way to go, not to fall back on ugly HTML again.


Geotag plugin change

Posted: Sat Mar 24, 2007 3:40 pm
by mrael2
I also changed line 63 of serendipity_event_geotag.php as follows:

$propbag->add('default', ',%GEO_LONG%+(%TITLE%)&amp;spn=0.1,0.1&amp;t=h');

This is a case where '&' needed to become '&amp;'

Re: Geotag plugin change

Posted: Sun Mar 25, 2007 1:58 pm
by garvinhicking

Thanks a lot, also committed this!


Another change

Posted: Fri Jun 29, 2007 5:49 pm
by mrael2
Here's another change I made. This time the file is serendipity_plugin_history.php. Lines 192 through 194 have been changed to add calls to htmlspecialchars as follows:

htmlspecialchars($e[$x]['title']) :
htmlspecialchars(trim(serendipity_mb('substr', $e[$x]['title'], 0, $maxlength-3)).' [...]');
echo $author . $date . "<a href='$url' title='".htmlspecialchars(str_replace("'", '`', $e[$x][title]))."'>".$t."</a> " .

Re: Another change

Posted: Sat Jun 30, 2007 1:31 pm
by garvinhicking

Thanks a lot, committed!