Ticket #4857 (assigned defect)

Opened 1 year ago

Last modified 5 months ago

More issues with wpautop()

Reported by: Viper007Bond Assigned to: mdawaffe (accepted)
Priority: low Milestone: 2.9
Component: Template Version: 2.3
Severity: normal Keywords: wpautop needs-patch
Cc: wptrac@viper007bond.com

Description

Not sure if this should slide into 2.3 or if it can wait for 2.4. Change as need be.

wpautop() has issues with closing </p>'s when it comes to HTML.

For example:

Foo<div>Bar</div>

Results in:

<p>Foo
<div>Bar</div>

Change History

08/31/07 01:25:23 changed by mdawaffe

Obviously what's generated is incorrect :)

What output do you expect?

(follow-up: ↓ 4 ) 08/31/07 19:08:09 changed by foolswisdom

  • milestone changed from 2.3 to 2.4 (next).

Viper007Bond a "real world" example would be great too, because when I look at that input I wonder if it isn't such an edge case that it could complicate solutions for more general problems.

09/04/07 10:01:18 changed by Viper007Bond

  • cc set to wptrac@viper007bond.com.

(in reply to: ↑ 2 ) 09/06/07 10:21:26 changed by Viper007Bond

Replying to foolswisdom:

Viper007Bond a "real world" example would be great too, because when I look at that input I wonder if it isn't such an edge case that it could complicate solutions for more general problems.

It seems to only do it with block level items.

For example:

This is some <pre>code</pre>

gets turned into:

<p>This is some
<pre>code</pre>

09/06/07 10:22:26 changed by Viper007Bond

I don't know how to get much more "real world" than that BTW. :/

11/06/07 00:57:55 changed by mdawaffe

  • keywords changed from needs-patch to wpautop needs-patch.
  • owner changed from anonymous to mdawaffe.
  • status changed from new to assigned.

I look at your first (and second) example and expect the paragraph to only wrap around "Foo":

<p>Foo</p>
<div>Bar</div>

since paragraph elements can only contain inline content*. For that reason, I do not expect the paragraph to wrap the whole thing:

mdawaffe thinks this is wrong

<p>Foo<div>Bar</div></p>

* http://www.w3.org/TR/xhtml1/dtds.html#dtdentry_xhtml1-strict.dtd_p

(in reply to: ↑ description ) 11/27/07 20:44:58 changed by whoismanu

Replying to Viper007Bond:

Not sure if this should slide into 2.3 or if it can wait for 2.4. Change as need be. wpautop() has issues with closing </p>'s when it comes to HTML. For example: {{{ Foo<div>Bar</div> }}} Results in: {{{ <p>Foo <div>Bar</div> }}}

obviously it didn't make it into 2.3 ;-( let's hope it will make it into 2.4. here is a real world example from my photoblog plugin. i hope it shows that the problem really is annoying whenever there is need to have some structured content in the content section of the post. i of course also hope it could help raise the priority level of this one ;-). so here you go:

my plugin writes an image plus a corresponding description into the post like this:

<img width="700" height="525" src="someimage.jpg" />
<p class="description">Description of image</p>

The p tag with css class is needed to give the user the possibility to style the result. so i cannot just use line breaks between the image and its description like the wordpress editor would do to separate paragraphs.

The result after it has been deformed by wpautop:

<p><img width="700" height="525" src="someimage.jpg" /> 
<p class="description">Description of image</p>

which is obviously not valid xhtml. what i would expect is

<img width="700" height="525" src="someimage.jpg" /> 
<p class="description">Description of image</p>

or if you really have to put p tags all over the place:

<p><img width="700" height="525" src="someimage.jpg" /></p> 
<p class="description">Description of image</p>

yes, the paragraph should not wrap the whole thing because of the reason you mention. yes, the bug concerns all blocklevel elements, so

<img width="700" height="525" src="someimage.jpg" />
<div class="description">Description of image</div>

results in

<p><img width="700" height="525" src="someimage.jpg" /> 
<div class="description">Description of image</div>

thanks a lot for fixing this.

02/09/08 06:14:33 changed by DD32

Issue Semi-resolved.

<img width="700" height="525" src="someimage.jpg" />
<p class="description">Description of image</p>

results in: (Incorrect, double <p>'s)

<p><img src="someimage.jpg" height="525" width="700" /></p>
<p><p class="description">Description of image</p></p>
<img width="700" height="525" src="someimage.jpg" />
<div class="description">Description of image</div>

results in: (Which seems to be correct?)

<p><img src="someimage.jpg" height="525" width="700" /></p>
<div class="description">Description of image</div>

Mind you, The resulting HTML in all cases seems to validate for me, But i'm pretty sure the nested <p>'s isnt right. (At least they're balanced now though)

03/28/08 18:42:35 changed by mdawaffe

  • milestone changed from 2.5 to 2.6.