< Sickbed Soup
Curry >

[Comments] (10) : Is this valid HTML?

<!  DOCTYPE HTML PUBLIC...

That is, as opposed to:

<!DOCTYPE HTML PUBLIC...

More generally, is it okay to have whitespace between the <! that begins a declaration and the actual name of the declaration? The W3C validator says it's fine, and I couldn't find anything in the standard about it, and the general SGML-based-language attitude towards whitespace is "whitespace is all in your head, maaaaan." However, there are intimations on various webpages that it's invalid, and the Python HTML parser chokes on it (this is a leading cause of complaints against Beautiful Soup). I have a fix for the Python HTML parser but before I put all the effort into making sure it doesn't break anything else I'd like to know if it's even something that's "supposed" to work.

Filed under:

Comments:

Posted by Zack at Sun Dec 12 2004 19:06

Beautiful Soup does not care. It seems to me that rejecting <! whitespace DOCTYPE constitutes caring.

Y'wanna add a preview display to NB comments? I can never remember whether or not one is supposed to escape one's own less-than signs.

Posted by Leonard at Mon Dec 13 2004 10:18

Yeah, I'm trying to figure out the best way of not caring. Do I fix Python (because it's a real bug in Python), or do I sanitize the input before giving it to the parser (because it's not valid HTML and the Python team decide to make their HTML parser more caring than Beautiful Soup)?

I don't *want* to add a preview display, but I guess I will eventually.

Posted by Zack at Mon Dec 13 2004 12:45

I see. I did some research which convinces me it's *not* valid XML, but I can't find an SGML spec online.

Posted by Brendan at Mon Dec 13 2004 14:38

Um, what about a preview for actual NB entries?

Posted by Andy H. at Mon Dec 13 2004 20:19

Yeah; it would sure help with those three or four immediate edits my entries inevitably go through (not that we're using a non-antiquated version of NewsBruiser anyway).

Posted by Zack at Tue Dec 14 2004 01:23

Isn't that what draft mode is for? (not that I'm even using NB at all)

Posted by Leonard at Tue Dec 14 2004 09:05

How about if the screen you get when you save as draft had an edit box on it, instead of just a rendering of the entry and a link to the edit screen?

Posted by Mark A. Hershberger at Tue Dec 14 2004 10:49

Not valid xml: http://www.w3.org/TR/2004/REC-xml-20040204/#NT-doctypedecl

Not valid sgml/html:
http://www.math.utah.edu/~beebe/software/html-pretty/html-pretty-08.html

Posted by Leonard at Tue Dec 14 2004 12:41

Thanks mah, that's exactly what I was looking for.

Posted by Brendan at Tue Dec 14 2004 16:08

Leonard, that would be great. The only problem I have with using draft mode as a preview is a bug in NB that I can't remember if I've ever reported. (I upgraded to 2.5 today and this still happens.)

If I hit the Publish Me! link from the you-just-made-a-new-draft screen, it publishes the entry but erases all my category selections and turns on comments for that entry, even though I always leave the box unchecked. If I hit Edit Me! directly from that same screen, it leaves comments unchecked but loses all my category selections. This only happens from that screen--going into my drafts folder and editing entries after they've been saved doesn't do it, and it never affects entries that aren't drafts.


[Main] [Edit]

Unless otherwise noted, all content licensed by Leonard Richardson
under a Creative Commons License.