Opened 5 years ago
Last modified 4 years ago
#48256 new defect (bug)
WP remove first <p> in <td>
Reported by: | Sebafaim | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | major | Version: | 5.2.3 |
Component: | Editor | Keywords: | needs-patch needs-unit-tests |
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)
Change History (9)
#2
in reply to:
↑ 1
@
5 years 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 ?
#4
@
5 years 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
@
4 years 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."
#6
@
4 years ago
- Keywords needs-unit-tests added; 2nd-opinion removed
- Milestone changed from Awaiting Review to Future Release
I was able to confirm this by pasting this into the Code Editor and previewing the page.
<div> <img src="https://source.unsplash.com/random/800x600" alt="" width="800" height="600" /> <p>Here is some paragraph</p> </div>
There is an extraneous </p>
which is invalid HTML.
Looks like a bug with wpautop. We should add tests that cover the edge case. Invalid HTML should never be produced.
@Sebafaim Please explain how can I reproduce it.