[wp-trac] [WordPress Trac] #42340: Spurious Insertion of <p>aragraph Tags

WordPress Trac noreply at wordpress.org
Tue Jul 2 01:54:34 UTC 2019


#42340: Spurious Insertion of <p>aragraph Tags
--------------------------+----------------------
 Reporter:  oeconomist    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Formatting    |     Version:
 Severity:  normal        |  Resolution:  wontfix
 Keywords:                |     Focuses:
--------------------------+----------------------
Changes (by pento):

 * status:  new => closed
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Comment:

 I understand that you want to insert custom HTML like this, but
 `wpautop()` is intended to be opinionated about how HTML is formatted: it
 deliberately interprets two consecutive `<br/>` tags as a paragraph break.

 The workarounds above are both correct. You can automate the latter by
 hooking into the `the_content` filter before `wpautop()` runs:

 {{{#!php
 <?php
 add_action( 'the_content' function( $content ) {
         return preg_replace( '|(<br\s*/?>\s*)(<br\s*/?>)|', '$1<!-- keep
 these line breaks -->$2', $pee );
 }, 9 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42340#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list