[wp-hackers] XHTML Strict Mode
Jamie Talbot
wphackers at jamietalbot.com
Tue Aug 3 10:23:27 UTC 2004
A open question to everyone...
"Fully Standards Compliant" - Does this mean just WP's own code and
structures, or taking into account all the poorly marked up posts and
comments a user can generate?
@Randy
It would be nice to use PHP 5's built in validation, but to require it
just to output valid code seems a little harsh, considering PHP 5 is
pretty new and hosts might be a little slow and reluctant in updating
to it. Plus, does the validation just alert the user, or does it fix
the problems? I would hazard a guess at the former...?
@Scott (coffee2code)
Looked at your code with interest, looks nice - I'll go and try to
break it tonight! :D Documentation is very clear by the way, nice
one. A few things I wondered about though, (without looking in depth
as yet)...
if($tag != 'br' && $tag != 'img' && $tag != 'hr' && $tag != 'input' &&
$tag != '')
seems a little strange. I take it this is to ignore self-closing
tags? It works as it is, but what about future self closing tags, or
tags you haven't thought of? A better way IMHO would be to check for
the self closing-ness directly, - something like...
if (substr($tag, -1) == "/")
or something similar. This would make it future proof, without having
to add to the list.
You mention it could fix the 'more' tag problem easily. Not sure this
is the case. I presume (tsk tsk) that you would just pop the stack
before the more tag? I think the only way it can be done at post time
is to make a store of the unbalanced tags somewhere in the db.
Otherwise, the inserted tags would break the structure when the entire
post was displayed. The alternative option is to divorce the 'more'
tag problem from post-time checking and do it at display-time which I
originally thought was a good idea, but now am not so sure of. More
at mosquito bug 178.
Balance Tags should also probably remove multiple instances of
the 'more' tag as it causes any text after the second tag to not be
displayed in "get-the-content" due to the explode(content) line.
Mosquito bug 113.
Like you say, this doesn't sort out wp-autop problems. I was thinking
more along the lines of taking all the formatting code (balance tags,
wp-autop, 'more' handling, etc..) and tying them all together in one
go. It makes sense to me at least to have all the code to format text
in one place, even if the only reason is future manageability. This
would involve a substantial rewrite though, with alterations to a
couple of files. Your code could easily be used a base for this.
Will go away and look again at this, and try to get back to you with
feedback tomorrow. (Japan time!)
Jamie.
--
http://www.jamietalbot.com/
>From: Scott Reilly <coffee2code at scottreilly.net>
>Reply-To: hackers at wordpress.org
>To: hackers at wordpress.org
>Subject: Re: [wp-hackers] XHTML Strict Mode
>Date: Mon, 2 Aug 2004 13:07:33 -0400
>
>For my (now late) contribution to WP Patch Day, I believe I've
actually fixed
>most of the WP code related to balancing tags. There are quite a
number of
>situations in which the tag balancer will (a) eat user text before it
reaches
>the database, (b) improperly balance tags, (c) not balance tags given
a
>certain scenario, (d) try to balance an HTML comment with '</>' (in
certain
>scenarios).
>
>The fixed balancer could also (with a one-line addition) be used to
balance
>text prior to <!--more--> upon request.
>
>I'm trying to write up extensive documentation on what changes I made
and why
>I made them. Anyone willing to volunteer to review the code when I'm
done
>and/or use it yourself to ensure that my changes didn't just fix the
problem
>scenarios I discovered while unbeknownst-to-me breaking other
scenarios?
>
>By no means, though, do my changes make it a true XHTML validator.
Merely a
>more fixed and more proper tag balancer, which I guess is part of the
road to
>XHTML validity.
>
>-Scott
>http://www.coffee2code.com
>
>
>On Monday 02 August 2004 12:11 pm, Jamie Talbot wrote:
> > Hi,
> >
> > I'm new to the list and have read most of the archives, but if
this a
> > repetition sorry!
> >
> > One of Matt's wishes on the PatchDay Wiki is an XML parser to check
> > for post and comment validity. I was wondering what, if any, work
is
> > being done in this area. I've been having a look at some of the
bugs
> > in Mosquito to do with unbalanced tags, problems with wp-autop and
> > errors caused by the use of the 'more' tag. Although I think there
> > are individual solutions to each of these problems, it would
probably
> > be best to combine them all together and roll out a combined
validity
> > checker / corrector.
> >
> > I'd be happy to begin working on this, and wanted to encourage some
> > discussion in this area.
> >
> > So, a few questions:
> >
> > What should Strict mode mean? Unbalanced tags only or full blown
> > validity checking? Should the user be alerted or should it be done
> > silently? There is a discussion about what to do with 'more' tags
in
> > bug 0000098 in Mosquito. Opinions welcomed on that too...
> >
> > Is anyone working on this at the moment? If not, is there anyone
who
> > wants to collaborate on it? It could be an involved process, so
the
> > more the merrier!
> >
> > Let me know your thoughts...
> >
> > Jamie.
> >
>
>_______________________________________________
>hackers mailing list
>hackers at wordpress.org
>http://wordpress.org/mailman/listinfo/hackers_wordpress.org
More information about the hackers
mailing list