diff --git a/lib/blocks.php b/lib/blocks.php index 1d7b76773d8eec..e28971bad032c2 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -199,6 +199,9 @@ function do_blocks( $content ) { // Append remaining unmatched content. $rendered_content .= $content; + // Strip remaining block comment demarcations. + $rendered_content = preg_replace( '/\r?\n?/m', '', $rendered_content ); + return $rendered_content; } add_filter( 'the_content', 'do_blocks', 9 ); // BEFORE do_shortcode(). diff --git a/phpunit/class-do-blocks-test.php b/phpunit/class-do-blocks-test.php new file mode 100644 index 00000000000000..ec7cd97c39bbdf --- /dev/null +++ b/phpunit/class-do-blocks-test.php @@ -0,0 +1,25 @@ +assertEquals( $expected_html, $actual_html ); + } +} diff --git a/phpunit/fixtures/do-blocks-expected.html b/phpunit/fixtures/do-blocks-expected.html new file mode 100644 index 00000000000000..89781ba3d31874 --- /dev/null +++ b/phpunit/fixtures/do-blocks-expected.html @@ -0,0 +1,12 @@ +
First Auto Paragraph
+ + + +First Gutenberg Paragraph
+ +Second Auto Paragraph
+ + +Third Gutenberg Paragraph
+ +Third Auto Paragraph
diff --git a/phpunit/fixtures/do-blocks-original.html b/phpunit/fixtures/do-blocks-original.html new file mode 100644 index 00000000000000..3707e7a857910d --- /dev/null +++ b/phpunit/fixtures/do-blocks-original.html @@ -0,0 +1,17 @@ +First Auto Paragraph
+ + + + +First Gutenberg Paragraph
+ + +Second Auto Paragraph
+ + + + +Third Gutenberg Paragraph
+ + +Third Auto Paragraph