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

WordPress Trac noreply at wordpress.org
Fri Nov 9 09:05:27 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 Chouby):

 The editor does not let me save
 {{{
 <!-- wp:core/paragraph -->
 <p>First paragraph</p>
 <!-- /wp:core/paragraph --><!-- wp:core/paragraph -->
 <p>Second paragraph</p>
 <!-- /wp:core/paragraph -->
 }}}
 It automatically changes it back to
 {{{
 <!-- wp:paragraph -->
 <p>First paragraph</p>
 <!-- /wp:paragraph -->

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

 I am not sure that this is intentional. But it's indeed probably a
 consequence of how the free form text is parsed as

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

 <p>Free form text</p>

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

 is parsed in

 {{{
 Array
 (
     [0] => Array
         (
             [blockName] => core/paragraph
             [attrs] => stdClass Object
                 (
                 )

             [innerBlocks] => Array
                 (
                 )

             [innerHTML] =>
 <p>First paragraph</p>

         )

     [1] => Array
         (
             [blockName] =>
             [attrs] => Array
                 (
                 )

             [innerBlocks] => Array
                 (
                 )

             [innerHTML] =>

 <p>Free form text</p>


         )

     [2] => Array
         (
             [blockName] => core/paragraph
             [attrs] => stdClass Object
                 (
                 )

             [innerBlocks] => Array
                 (
                 )

             [innerHTML] =>
 <p>Second paragraph</p>

         )

 )
 }}}

 Maybe not a big deal, but it surprised me having all these empty blocks in
 the array returned.

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


More information about the wp-trac mailing list