Skip to content

Converting a <pre> to blocks drops new lines #12109

@johngodley

Description

@johngodley

If you open an old post in Gutenberg it will put the contents in a classic block. If this classic block contains a <pre> section and you then convert that to blocks it removes the new lines in the editor.

edit_post_ _wordpress_latest_ _wordpress

HTML is:

<pre>line1
line2
line3
</pre>

From the block options pick 'convert to blocks' and get:

edit_post_ _wordpress_latest_ _wordpress

Note that this is only in the Gutenberg editor, where the code is:

edit_post_ _wordpress_latest_ _wordpress

When viewed in the post the <pre> is correct:

test_pre_ _wordpress_latest

Expected behavior

Either the <pre> conversion should add the <br/> tags that occur when created in Gutenberg, or the preformatted block should insert breaks in the display when a new line is encountered.

Metadata

Metadata

Labels

[Block] ClassicAffects the Classic Editor Block[Feature] Block TransformsBlock transforms from one block to another[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions