[wp-hackers] XHTML Strict Mode

Scott Reilly coffee2code at scottreilly.net
Thu Aug 5 22:59:47 UTC 2004


>
> Comments, bug reports and all welcomed - submission info is in the
> plugin file.
>

I had a brief opportunity to test the function earlier today and have 
mentioned some of the issues I came across below.  While I don't doubt that 
the issues can be resolved, I'm not sold on the need to completely rewrite 
the tag balancer.  It's code that has been in place for many years, and with 
its recent changes, should do its job of tag balancing very well.  As I noted 
in my previous post, detecting self-closing tags has been accomplished with 
minimal change, and a minor change to wp-admin/post.php (patch forthcoming) 
will ensure balancing only happens on published (and not drafted) posts.  I 
acknowledge I may not be seeing another benefit to this different approach.

Some issues I encountered testing counterbalance() (I renamed it balanceTags() 
and used it to replace the core's balanceTags() to test and didn't run it as 
a plugin):

1.) ------------------------------

<b>aaa<i>bbb</b>ccc

yielded:

<b>aaa</b><i>bbbccc</i>

(In this case, it is the <i> that is unbalanced, and therefore should be 
closed as late as possible (which would be just before </b>):
<b>aaa<i>bbb</i></b>ccc

2.) ------------------------------

<ul>
<li>aaa
<li>bbb
<li>ccc</li>
</ul>

yielded:

<ul>
<li>aaa
</li></ul><li>bbb
</li><li>ccc</li>

3.) ------------------------------

<b>aaaa<div>bbb</div><i>ccc<hr />

yielded:

<b>aaaa</b><div>bbb</div><i>ccc<hr />
</i>

(I feel balancing should close tags as late as possible; so for this, since 
there is nothing in this example to prevent the <b> from being closed at the 
end:
<b>aaaa<div>bbb</div><i>ccc<hr /></i></b>

4.) ------------------------------

here is 34 < 234

yielded:

here is 34 < 234 </>

5.) ------------------------------

<div>aaa<div>bbb<div>ccc</div></div></div>

yielded:

<div>aaa</div><div>bbb</div><div>ccc</div>

(the original text is valid as-is)


6.) ------------------------------

<b><b>text</b>

yielded:

<b><b>text</b></b>

(but you already noted this situation)



-Scott
http://www.coffee2code.com




More information about the hackers mailing list