Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#51302 closed defect (bug) (duplicate)

Lots of newlines in REST API rendered content when using block editor

Reported by: rmens's profile rmens Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.5.1
Component: Editor Keywords:
Focuses: rest-api Cc:

Description

In a post created with the block editor i have the following

<!-- wp:paragraph -->
<p>This is paragraph 1</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This is paragraph 2</p>
<!-- /wp:paragraph -->

But the REST API renders the content as

"\n<p>This is paragraph 1</p>\n\n\n\n<p>This is paragraph 2</p>\n"

There seem to be 4 newlines between the paragraphs, while there should only be one. When I make the same post in the classic editor, it comes out like this. Which looks more correct.

"<p>This is paragraph 1</p>\n<p>This is paragraph 2</p>\n"

Change History (4)

#1 @joyously
4 years ago

Are the block marker comments being converted to \n?

#2 @rmens
4 years ago

Hi @joyously, after some more testing this does seem to be the case. Normal HTML-comments like <!-- this is a comment --> don't convert to \n but block markers are.

Version 0, edited 4 years ago by rmens (next)

#3 @TimothyBlynJacobs
4 years ago

  • Component changed from REST API to Editor
  • Focuses rest-api added

I'm moving this to the Editor component as it is responsible for rendering the raw content, the REST API only applies the the_content filter.

#4 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome back to WordPress Trac!

Thanks for the report, we're already tracking this issue in #46655.

Note: See TracTickets for help on using tickets.