WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#37328 closed defect (bug) (duplicate)

Empty <p> tag inside <figure> markup

Reported by: henry.wright Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Formatting Keywords:
Focuses: Cc:

Description

<figure>
<img src="image.png" alt="">
<figcaption>Caption</figcaption>
</figure>

Using the above markup in the form at Posts > Add New results in an empty <p> tag being output. For example:

<figure>
<img src="image.png" alt=""><p></p>
<figcaption>Caption</figcaption>
</figure>

Interesting, if I remove all whitespace from the markup I enter in the post form:

<figure><img src="image.png" alt=""><figcaption>Caption</figcaption></figure>

... I get a <br> tag instead of the <p></p>:

<figure><img src="image.png" alt=""><br>
<figcaption>Caption</figcaption>
</figure>

I believe the empty <p> is a bug with wpautop().

Change History (5)

#1 follow-up: @lukecavanagh
5 years ago

@henry.wright

So what happens if you disable the wpautop filter?

https://codex.wordpress.org/Function_Reference/wpautop

#2 in reply to: ↑ 1 @henry.wright
5 years ago

Replying to lukecavanagh:

So what happens if you disable the wpautop filter?

The problem doesn't happen when the filter is disabled.

#3 @lukecavanagh
5 years ago

@henry.wright

Okay, well that helps find the exact cause then.

#4 @ocean90
5 years ago

  • Component changed from Editor to Formatting
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

The output is actually

<figure>
<img src="image.png" alt=""></p>
<figcaption>Caption</figcaption>
</figure>

The <p> gets added by the browser. This is already mentioned in #15918.

The second issue with the <br> tag is tracked in #27559.

#5 @henry.wright
5 years ago

@ocean90 no wonder my string replace tinkering didn't work for <p></p> 😃

Note: See TracTickets for help on using tickets.