Skip to content

1.9.1: Gutenberg breaks "classic" posts w/ shortcodes by carelessly wrapping shortcodes into <p> tags #3900

@lkraav

Description

@lkraav

(EDIT 2018-02-23 still broken in 2.2.0)
(EDIT 2018-03-06 still broken in 2.3.0)
(EDIT 2018-07-04 still broken in 3.1.1)
(EDIT 2018-07-21 still broken in 3.3.0)

Issue Overview

It is not safe to open classic posts in Gutenberg, shortcodes get unexpectedly wrapped in <p> tags.

Steps to Reproduce (for bugs)

  1. Author a new post in classic editor w/ this example content
<h2>Shinier than yours, meatbag.</h2>

You can crush me but you can't crush my spirit! Is today's hectic lifestyle making you tense and impatient? It's a T. It goes "tuh". I'll tell them you went down prying the wedding ring off his cold, dead finger.

[column]

I daresay that Fry has discovered the smelliest object in the known universe! For the last time, I don't like lilacs! Your 'first' wife was the one who liked lilacs! No argument here. A true inspiration for the children.

[/column]

Hello world.
  1. Open this post in Gutenberg
  2. Switch to Code Editor mode to review transformed markup

Expected Behavior

I'm not sure what the latest transformation goal for classic posts is. <!-- wp:freeform --> seems to be gone? Is #2454 relevant to the issue at hand?

Current Behavior

I see the following transformation in Code Editor, which I consider broken for the shortcodes, since the result is broken rendering on the frontend:

<h2>Shinier than yours, meatbag.</h2>
<p>You can crush me but you can't crush my spirit! Is today's hectic lifestyle making you tense and impatient? It's a T. It goes "tuh". I'll tell them you went down prying the wedding ring off his cold, dead finger.</p>
<p>[column grid="2" span="1"]</p>
<p>I daresay that Fry has discovered the smelliest object in the known universe! For the last time, I don't like lilacs! Your 'first' wife was the one who liked lilacs! No argument here. A true inspiration for the children.</p>
<p>[/column]</p>
<p>[column grid="2" span="1"]</p>
<p>Hello world.</p>
<p>[/column]</p>

"Convert to blocks" also gets completely confused by this result and fails to separate shortcodes into their own blocks.

Possible Solution

Not sure, could use pointers. What instructions should I provide users to avoid insta-breaking all classic content saved in Gutenberg?

Screenshots / Video

N/A

Related Issues and/or PRs

Not sure, could use pointers.

Metadata

Metadata

Labels

[Feature] ShortcodesRelated to shortcode functionality[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions