Skip to content

Commit

Permalink
Use gutenberg_content_has_blocks to check for existance of blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 11, 2017
1 parent ffa08ac commit 357f409
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function gutenberg_parse_blocks( $content ) {
* If there are no blocks in the content, return a single block, rather
* than wasting time trying to parse the string.
*/
if ( ! preg_match( '/<!--\s*(wp:|more|noteaser)/', $content ) ) {
if ( ! gutenberg_content_has_blocks( $content ) ) {
return array(
array(
'attrs' => array(),
Expand Down
3 changes: 2 additions & 1 deletion phpunit/class-parsing-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function test_parser_output( $html_filename, $parsed_json_filename ) {
$html = self::strip_r( file_get_contents( $html_path ) );
$expected_parsed = json_decode( self::strip_r( file_get_contents( $parsed_json_path ) ), true );

$result = gutenberg_parse_blocks( $html );
$parser = new Gutenberg_PEG_Parser;
$result = $parser->parse( _gutenberg_utf8_split( $html ) );

$this->assertEquals(
$expected_parsed,
Expand Down

0 comments on commit 357f409

Please sign in to comment.