WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.18k forks source link

Removing wpautop does not work in Gutenberg #11895

Closed orchidGem closed 4 years ago

orchidGem commented 5 years ago

Describe the bug Removing the wpautop filter does not work when Gutenberg is activated. I write all of my content in posts and pages written in the text editor and have wpautop removed for all of my sites using remove_filter('the_content', 'wpautop'); This works fine in Classic editor, however when Gutenberg is installed it adds paragraphs and break tags and shifts content around and thus breaks the user front end of the pages.

To Reproduce Steps to reproduce the behavior:

  1. Make sure Gutenberg is not installed
  2. Write html inside the text tab of the editor <p>Test</p> <img src="" />
  3. Add remove_filter('the_content', 'wpautop'); to functions file
  4. View page to ensure html is rendered same is written in text editor
  5. Install and activate Gutenberg
  6. View page and you will see the image tag is wrapped in a p tag now

Expected behavior I expect backwards compatibility for this. I cannot take my sites live with the Gutenberg editor if this does not work as before. I plan to move everything to either blocks or the new html block at some point, but this is manual work that will take time and the site needs to look and function the same in the meantime.

designsimply commented 5 years ago

@orchidGem could you note the versions of WordPress and the Gutenberg plugin you tested with for reference?

designsimply commented 5 years ago

Thank you for the clear set of testing steps!

I tested and confirmed that <p> tags are added around the <img> tag from the sample content after adding remove_filter('the_content', 'wpautop'); to functions.php in the Twenty Seventeen theme when using WordPress 4.9.8 and Gutenberg 4.3. (screenshots)

Next, I tested the same steps with WordPress 5.0-beta4-43896 (no Gutenberg plugin) using the classic block and I found that the sample content <p>Test</p> <img src="" /> became Test <img src="" />.

(If I am reading correctly!) I think that the intention is for it to be as backward-compatible as possible in the sense that it should work as closely as possible with WP4.9.8 (no plugin) and WP5.0 final. This is my interpretation after reading https://core.trac.wordpress.org/ticket/45290 and I think the next step will be to find out if the behavior where <p>Test</p> <img src="" /> becomes Test <img src="" /> is the expected outcome or not because I noticed that switching from text to visual and back to text using WP4.9.8 (no Gutenberg plugin) has the same result of Test <img src="" />.

I added Needs Technical Feedback label to get help finding out the intended behavior and to ask whether this case should be reported upstream at https://core.trac.wordpress.org/ or not given the changeset at https://core.trac.wordpress.org/changeset/43879

orchidGem commented 5 years ago

@orchidGem could you note the versions of WordPress and the Gutenberg plugin you tested with for reference?

I am using WP version 4.9.8 and Gutenberg version 4.3.0

loratov commented 5 years ago

@designsimply I just tested it with the 5.0 beta as well and now the layout, just after installing wordpress, is fine ( removing the wpautop filter still works after the 5.0 update).

However, I experience issues when I edit the page in the admin.

If I edit the page in the visual editor, and I click Edit HTML for the block, then the html shows as <p>Test</p> <p><img src="" /></p> So it's wrapping the image in a p tag edit page wordpress playground wordpress edit page wordpress playground wordpress 1

If I edit the page in the code editor, then the html shows as Test <img src="" />

So it's removing the p tag that was originally surrounding the Test text. edit page wordpress playground wordpress 2

Ideally I would like to eventually copy the html that was in the classic editor and move it to the new html block, however, I can't trust that it won't add or remove elements that were originally in the html.

lkraav commented 5 years ago

@loratov you should not be using Gutenberg-global "Code Editor" to achieve that goal. It will try to re-parse everything into modern block format, and it should keep doing that.

For maintaining HTML as-is, use the HTML block, and paste HTML in there.

It will remove the ability to edit content in Visual mode, though.

I think the long-term smarter thing to do is actually let Gutenberg reformat your content with proper tag semantics, but I fully understand not everyone has the time/energy to undertake such a project.

gziolo commented 5 years ago

I just tested it with the 5.0 beta as well and now the layout, just after installing wordpress, is fine ( removing the wpautop filter still works after the 5.0 update).

Yes, it should be fixed. This issue existed pre-5.0.

youknowriad commented 4 years ago

I'm closing this as the original issue here is fixed.