[wp-trac] [WordPress Trac] #14050: shortcode_unautop() should also remove the <br /> added after shortcodes

WordPress Trac noreply at wordpress.org
Wed Feb 11 22:03:17 UTC 2015


#14050: shortcode_unautop() should also remove the <br /> added after shortcodes
-----------------------------------+-----------------------------
 Reporter:  aaroncampbell          |       Owner:  aaroncampbell
     Type:  defect (bug)           |      Status:  assigned
 Priority:  normal                 |   Milestone:  Future Release
Component:  Formatting             |     Version:  3.0
 Severity:  normal                 |  Resolution:
 Keywords:  needs-refresh wpautop  |     Focuses:
-----------------------------------+-----------------------------

Comment (by aaroncampbell):

 So, I didn't forget about this ticket and I haven't been ignoring it. It's
 just that the issues here are somewhat more complex that I remembered them
 being. I'm working up some more extensive tests to show what I mean, but
 here are the basics:
 * `wpautop()` is complex (and pees all over the place), but is blissfully
 unaware of shortcodes
 * It's bliss, unfortunately, causes inconsistencies in how it handles
 them.
 * `shortcode_unautop()` uses mostly the logic of the shortcode processor
 (very similar regex) to try to undo what `wpautop()` does, but it's
 definitely not succeeding

 Here are the three main scenarios, one of which (likely the most common
 usecase) works:
 * When a shortcode has an empty line or the start or end of the post
 before or after it (so two new lines before or after), it is wrapped in a
 `<p>` tag. When `shortcode_unautop()` is run, the `<p>` tag is removed.
 * A shortcode that is immediately followed by another shortcode (no new
 line) results in both shortcodes being wrapped in a `<p>` tag
 (`<p>[shortcode1][shortcode2]</p>`). When `shortcode_unautop()` is run,
 the `<p>` tag is not removed.
 * A shortcode that is followed by another shortcode on the next line
 (single new line) results in both shortcodes being wrapped in a single
 `<p>` tag, with a `<br>` between them (`<p>[shortcode1]<br
 />[shortcode2]</p>`). When `shortcode_unautop()` is run, neither the `<p>`
 tag nor the `<br>` are removed.

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


More information about the wp-trac mailing list