WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 6 months ago

#48256 new defect (bug)

WP remove first <p> in <td>

Reported by: Sebafaim Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 5.2.3
Component: Editor Keywords: needs-patch 2nd-opinion
Focuses: Cc:

Description

When I create table and add text inside it remove first <p> but let </p>
Example : <td><span class="" ></span></p>

Attachments (3)

TinyMCE Advanced editor.png (155.8 KB) - added by samful 6 months ago.
source-code.png (30.0 KB) - added by samful 6 months ago.
front-end.png (83.4 KB) - added by samful 6 months ago.

Download all attachments as: .zip

Change History (8)

#1 follow-up: @mohsinrasool
13 months ago

@Sebafaim Please explain how can I reproduce it.

#2 in reply to: ↑ 1 @Sebafaim
13 months ago

Replying to mohsinrasool:

@Sebafaim Please explain how can I reproduce it.

I create a table with TinyMCE Advanced, and I add text inside the cell, and after I save.
I'm not doing anything else. Maybe wpautop ?

#3 @SergeyBiryukov
13 months ago

  • Component changed from General to Editor
  • Focuses coding-standards removed

#4 @alpipego
10 months ago

  • Keywords needs-patch added
  • Severity changed from minor to major

In wpautop a block element immediately followed by an inline(-block) element causes this issue. For me it was <div><img …>…</div> getting turned into <div><img …></p>…</div>.

The issue is that markup like this:

<div>
    <img src="https://source.unsplash.com/random/800x600" alt="" width="800" height="600" />
    <p>Here is some paragraph</p>
</div>

gets split into

<div><img src="https://source.unsplash.com/random/800x600" alt="" width="800" height="600" />
<p>Here is some paragraph</p>
<div>

concatenated to

<p><div><img src="https://source.unsplash.com/random/800x600" alt="" width="800" height="600" /></p>
<p><p>Here is some paragraph</p></p>
<p></div></p>

The opening <p> then gets removed for the first fragment above in https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php#L578 but the closing one stays.

I've changed the severity to major, since this leads to invalid HTML markup in the output.

#5 @samful
6 months ago

  • Keywords 2nd-opinion added

This ticket was never really very well explained, so I will try and explain my understanding of it:

The Issue:

Using the "TinyMCE Advanced" plugin and gutenburg causes some custom html to be deleted.

Examples Given:

<td><span class="" ></span></p>

removes the <p> element

<div>
    <img src="https://source.unsplash.com/random/800x600" alt="" width="800" height="600" />
    <p>Here is some paragraph</p>
</div>

Adds some <p> elements and then the opening <p> gets deleted

My Observation:

I experienced no issues at all and submitted screen-shots of my example. Also, yes there is a line in wpautop which deletes the opening <p> ,but also there is a line that deletes the closing <p> right next to it: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php#L581

If someone else can replicate the original issue with proof or confirm what I found, then please reply with screen-shots or close the ticket.


p.s. there is also a setting in that plugin to "Keep paragraph tags in the Classic block and the Classic Editor"

"Stop removing <p> and <br> tags in the Classic Editor and show them in the Text tab. This will make it possible to use more advanced coding in the Text tab without the back-end filtering affecting it much. However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently. Line breaks in the Text tab in the Classic Editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple <br> tags."

@samful
6 months ago

@samful
6 months ago

Note: See TracTickets for help on using tickets.