WordPress.org

Make WordPress Core

Opened 11 months ago

Last modified 11 months ago

#45829 new defect (bug)

New editor replaces > with &gt; within <pre> tag

Reported by: yannsalmon Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 5.0.2
Component: Editor Keywords: dev-feedback needs-patch
Focuses: javascript Cc:
PR Number:

Description

Hi,
I just updated to WordPress 5 and started using the new block editor.

I typeset source code in my posts using a <pre> tag. This code contains a > comparison operator. Upon saving my draft, > gets replaced with &gt;, and this entity is also displayed in the article preview.

This happens even if I disable the visual editor.

The old editor does not present this bug and installing the Classic Editor extension allowed me to work around this.

Change History (1)

#1 @subrataemfluence
11 months ago

  • Focuses javascript added
  • Keywords dev-feedback needs-patch added

You are right!

Actually the behavior is quite strange. I have the following code:

<pre><div></div></pre>

When I look into HTML it turns to

<p>&lt;pre><br>&lt;div><br>&lt;/div><br>&lt;/pre></p>

Not all < are converted to &lt; <br>, <p> and </p> all are fine.
For hand written HTML tags like pre and div, > are not converted to &gt;.

It looks like default HTML tags rendered by Gutenberg are fine. The strange behavior starts with HTML tags we write by hand!

Last edited 11 months ago by subrataemfluence (previous) (diff)
Note: See TracTickets for help on using tickets.