#39307 closed defect (bug) (fixed)
</p> tag inserted in <figure>
Reported by: | sujag | Owned by: | azaozz |
---|---|---|---|
Milestone: | 4.7.3 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Formatting | Keywords: | needs-testing fixed-major |
Focuses: | Cc: |
Description
since wordpress 4.7 HTML entered in "text" mode results in invalid result. Stray </p> get's inserted into <figure> after image-Element.
post content
<figure><img src="/wp-content/uploads/example.jpg" alt="something" /><figcaption>Caption</figcaption></figure>
generated markup note wrong </p> after <img>
<figure><img src="/wp-content/uploads/example.jpg" alt="something" /></p> <figcaption>Caption</figcaption> </figure>
Up to 4.6 this could be avoided by writing the whole figure-Element in one line, this workaround doesn't help anymore in 4.7
Attachments (3)
Change History (27)
#2
@
8 years ago
- Keywords needs-patch needs-unit-tests added
- Milestone changed from Awaiting Review to 4.7.1
I think this needs to be fixed with an exception in wpautop()
, similar to object tags - the assumption is that flow elements inside of block elements (in this case, <img>
inside <figure>
), need to be wrapped in a <p>
, but that's not the normal use case for <figure>
, which is usually just an <img>
and <figcaption>
(in either order).
Things get a little weird with spacing inside of block elements (see #38656), the tests for this should ensure that fun combinations of spacing and ordering don't make it go haywire.
#3
@
8 years ago
Yeah, think we need an exception here too.
Perhaps can have another "group" of tags that should not be wrapped in <p> and require specific parent tags. Candidates for there would be figcaption
, track
, source
, param
.
#4
@
8 years ago
In 39307.patch: Collapse line breaks inside <figure>
, and before and after <figcaption>
.
This will effectively remove any <p> inside of <figure>, above or below <figcaption> (which are allowed but very rarely used). These weren't working properly before 4.7, so don't expect it to cause any regressions.
#6
@
8 years ago
I am seeing similar problem in this ticket https://core.trac.wordpress.org/ticket/39377
#7
@
8 years ago
- Keywords needs-unit-tests removed
I have added a test for this while I was creating one the other ticket
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
#11
@
8 years ago
In 39307.2.patch: similar to 39307.patch but does not remove line breaks from directly inside <figure>
tags. This is closer to the previous behavior.
Still needs testing with older posts containing these tags to confirm there are no regressions.
#12
@
8 years ago
- Milestone changed from 4.7.1 to 4.7.2
Seems better to try to test this more before adding in a dot release.
#13
@
8 years ago
- Owner set to azaozz
- Resolution set to fixed
- Status changed from new to closed
In 39912:
#14
@
8 years ago
- Keywords needs-testing added; has-unit-tests has-patch removed
Reopen for 4.7.2 consideration.
#17
in reply to:
↑ 16
@
8 years ago
Replying to pbearne:
Was looking at "unifying" the tests for figcaption, track, source, param, as they are almost identical. But probably better to keep it simple and easier to read :)
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
#20
@
8 years ago
- Keywords fixed-major added
Per @jnylen0 in today's bug scrub in #core: Adding fixed-major
keyword as this ticket has a couple of commits already.
#21
follow-up:
↓ 22
@
8 years ago
@azaozz Is this clear for 4.7.x? or is extra work and/or testing needed?
Hi @sujag, thanks for the bug report.
Confirmed. Caused by [38592], see #4857. Without that change it inserts a <br> which is still a bug but at least doesn't visually alter the output (single closing
</p>
is converted to empty<p></p>
in the browsers).