Skip to content

Commit

Permalink
Merge pull request #1190 from WordPress/update/php-block-parser-for-e…
Browse files Browse the repository at this point in the history
…mpty-blocks

Update PHP “parser” to recognize shorthand block syntax
  • Loading branch information
westonruter authored Jun 17, 2017
2 parents 0bf22a4 + 578b386 commit 0579d08
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ function do_blocks( $content ) {
global $wp_registered_blocks;

// Extract the blocks from the post content.
$open_matcher = '/<!--\s*wp:([a-z](?:[a-z0-9\/]+)*)\s+((?:(?!-->).)*)-->.*?<!--\s*\/wp:\g1\s+-->/';
preg_match_all( $open_matcher, $content, $matches, PREG_OFFSET_CAPTURE );
$matcher = '/<!--\s*wp:([a-z](?:[a-z0-9\/]+)*)\s+((?:(?!-->).)*)\s*\/?-->(?:.*?<!--\s*\/wp:\g1\s+-->)?/';
preg_match_all( $matcher, $content, $matches, PREG_OFFSET_CAPTURE );

$new_content = $content;
foreach ( $matches[0] as $index => $block_match ) {
Expand All @@ -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 );

Expand Down

0 comments on commit 0579d08

Please sign in to comment.