Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#48196 new defect (bug)

The Code Editor generates tag soup with empty paragraphs in td elements

Reported by: vinc17's profile vinc17 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2.3
Component: Editor Keywords: reporter-feedback
Focuses: Cc:


When using the Code Editor with WordPress 5.2.3, the opening <p> and closing </p> tags do not appear in the editor and are automatically handled by the editor. If I try to add them to fix things, they are automatically removed. So, now the problem with this automatic handling: The Code Editor generates tag soup with empty paragraphs in td elements. For instance, the generated HTML code looks like this:

<td>text<br />
<p>text<br />

There are two issues (maybe related). First, this is tag soup. For various reasons (parsing with XML tools, better HTML code understanding and maintenance...), the Code Editor should not omit opening and closing tags. Here, the first </p> does not have a matching opening tag and the last <p> does not have a matching closing tag. Moreover, in HTML5 parsing, the first </p> is parsed as if it were <p></p>, i.e. an empty paragraph; and the text before it should really be in a paragraph for consistency. If the Code Editor thought that the <td> implied an opening <p> just after it, it is wrong! In short, the generated code should be:

<td><p>text<br />
<p>text<br />

Change History (1)

#1 @noisysocks
3 years ago

  • Keywords reporter-feedback added

Welcome @vinc17.

Could you please provide some steps to follow which shows how to get the editor to generate that invalid markup?

<p>s are automatically generated by WordPress by design. This can be disabled using the wpautop filter.

Note: See TracTickets for help on using tickets.