[wp-trac] Re: [WordPress Trac] #7988: wpautop p (paragraph) bug with div

WordPress Trac wp-trac at lists.automattic.com
Tue Oct 28 14:11:54 GMT 2008


#7988: wpautop p (paragraph) bug with div
--------------------------------------------+-------------------------------
 Reporter:  filosofo                        |        Owner:  anonymous
     Type:  defect                          |       Status:  new      
 Priority:  normal                          |    Milestone:  2.7      
Component:  General                         |      Version:  2.7      
 Severity:  normal                          |   Resolution:           
 Keywords:  wpautop p formatting has-patch  |  
--------------------------------------------+-------------------------------
Comment (by filosofo):

 Okay, I fixed the patch.

 The problem with the example "fixed" line in OP,

 {{{$pee = preg_replace('!<p>([^<\s]+)\s*?(</(?:div|address|form)[^>]*>)!',
 "<p>$1</p>$2", $pee);}}}

 is that it doesn't work when the non-markup stuff between the {{{<p>}}}
 and the {{{</div>}}}, etc. has a space in it, e.g.:

 {{{<p>text </div>}}} is fine but {{{<p>text text </div>}}} is not.

 To fix that, the current patch uses this line instead:

 {{{$pee =
 preg_replace('#<p>\s*?(?!\s)([^<]+)\s*?(</(?:div|address|form)[^>]*>)#',
 "<p>$1</p>$2", $pee);}}}

 {{{\s*?}}} gobbles up any space after the {{{<p>}}}.  Next, the negative
 lookaround, {{{(?!\s)}}}, makes sure that the non-markup stuff does not
 begin with a space, which is what it would do if it were all space.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/7988#comment:2>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list