[wp-trac] [WordPress Trac] #45312: parse_blocks return non-existing empty blocks

WordPress Trac noreply at wordpress.org
Fri Nov 9 00:48:12 UTC 2018


#45312: parse_blocks return non-existing empty blocks
--------------------------+------------------------------
 Reporter:  Chouby        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Editor        |     Version:  5.0
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by birgire):

 @Chouby I think this could be intentional, keeping the "freeform blocks"
 in between blocks.

 Now there's a {{{core}}} namespace, so one could also test:

 {{{
 <!-- wp:core/paragraph -->
 <p>First paragraph</p>
 <!-- /wp:core/paragraph -->

 <!-- wp:core/paragraph -->
 <p>Second paragraph</p>
 <!-- /wp:core/paragraph -->

 }}}

 yielding the same result, with an extra non-block.

 It seems we could remove these new-lines-only freeform blocks, by checking
 if the trimmed sub-string of the document is non-empty, in the
 {{{WP_Block_Parser_Block::add_block_from_stack()}}}, before adding the
 freeform block to the output.

 But then the {{{WP_Test_Block_Render::test_do_blocks_removes_comments()}}}
 will fail, because two new lines are being removed.

 So at first glance these kind of freeform blocks seems to be intentional.

 Maybe you see it differently @Chouby ?

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


More information about the wp-trac mailing list