Formatting: Add correct `<p>` tags near `<hr>` tags.

It can be tricky to know when `wpautop()` should add `<p>` tags, but one thing we can be certain about is that they really shouldn't be anywhere near `<hr>` tags.

Now they aren't.

Props solarissmoke, MattyRob, pento.
Fixes #14674.



git-svn-id: https://develop.svn.wordpress.org/trunk@45574 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2019-06-28 07:15:31 +00:00
parent b9cd66f483
commit 77764a5754
2 changed files with 12 additions and 1 deletions

View File

@ -500,6 +500,9 @@ function wpautop( $pee, $br = true ) {
// Add a double line break below block-level closing tags.
$pee = preg_replace( '!(</' . $allblocks . '>)!', "$1\n\n", $pee );
// Add a double line break after hr tags, which are self closing.
$pee = preg_replace( '!(<hr\s*?/?>)!', "$1\n\n", $pee );
// Standardize newline characters to "\n".
$pee = str_replace( array( "\r\n", "\r" ), "\n", $pee );

View File

@ -312,7 +312,6 @@ Paragraph two.';
'h4',
'h5',
'h6',
'hr',
'fieldset',
'legend',
'section',
@ -558,4 +557,13 @@ line 2<br/>
$this->assertEquals( $expected2, trim( wpautop( $content2 ) ) );
}
/**
* @ticket 14674
*/
function test_the_hr_is_not_peed() {
$content = 'paragraph1<hr>paragraph2';
$expected = "<p>paragraph1</p>\n<hr>\n<p>paragraph2</p>";
$this->assertEquals( $expected, trim( wpautop( $content ) ) );
}
}