diff --git a/lib/blocks.php b/lib/blocks.php index bffc2f1645396..1d5692889b091 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -102,8 +102,8 @@ function do_blocks( $content ) { global $wp_registered_blocks; // Extract the blocks from the post content. - $open_matcher = '/).)*)-->.*?/'; - preg_match_all( $open_matcher, $content, $matches, PREG_OFFSET_CAPTURE ); + $matcher = '/).)*)\s*\/?-->(?:.*?)?/'; + preg_match_all( $matcher, $content, $matches, PREG_OFFSET_CAPTURE ); $new_content = $content; foreach ( $matches[0] as $index => $block_match ) { @@ -114,7 +114,6 @@ function do_blocks( $content ) { } $block_markup = $block_match[0]; - $block_position = $block_match[1]; $block_attributes_string = $matches[2][ $index ][0]; $block_attributes = parse_block_attributes( $block_attributes_string );