[wp-trac] [WordPress Trac] #42222: editor removing pre tag

WordPress Trac noreply at wordpress.org
Tue Oct 24 19:38:55 UTC 2017


#42222: editor removing pre tag
--------------------------+------------------------------
 Reporter:  joyously      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Editor        |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  close         |     Focuses:
--------------------------+------------------------------

Comment (by joyously):

 Replying to [comment:1 iseulde]:
 > Looking at the GIF, the HTML seems to be invalid. The H2 tag cannot be
 inside of a PRE tag: https://html.spec.whatwg.org/multipage/grouping-
 content.html#the-pre-element.

 Just because the HTML is invalid (although that HTML still displays
 correctly in the browser), is no reason to strip out the `pre` tag. Since
 the only way to get the `pre` tag in there is to switch to Text mode, and
 then switch back to Visual to see how it looks, the editor could easily
 mess up a user's hard work. Even if it gave an indication of the problem,
 that would be better than silently removing what the user chose to put.

 As you can see in the second attachment, there is still a problem with how
 the `pre` tag is handled when the invalid tags are removed. The HTML
 entity replacement does not preserve the whitespace, which is the whole
 point of `pre`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42222#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list