WordPress.org

Make WordPress Core

Changeset 38592


Ignore:
Timestamp:
09/12/2016 07:05:28 AM (21 months ago)
Author:
pento
Message:

Formatting: Add an extra line break before block elements in wpautop().

wpautop() considers double line breaks to be the separator between block level HTML elements. By adding two line breaks before a block element, this allows us to process the text before a block element correctly.

Fixes #4857.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r38459 r38592  
    470470
    471471    // Add a single line break above block-level opening tags.
    472     $pee = preg_replace('!(<' . $allblocks . '[\s/>])!', "\n$1", $pee);
     472    $pee = preg_replace('!(<' . $allblocks . '[\s/>])!', "\n\n$1", $pee);
    473473
    474474    // Add a double line break below block-level closing tags.
  • trunk/tests/phpunit/tests/formatting/Autop.php

    r33955 r38592  
    525525    }
    526526
     527
     528    /**
     529     * @ticket 4857
     530     */
     531    function test_that_text_before_blocks_is_peed() {
     532        $content = 'a<div>b</div>';
     533        $expected = "<p>a</p>\n<div>b</div>";
     534
     535        $this->assertEquals( $expected, trim( wpautop( $content ) ) );
     536    }
    527537}
Note: See TracChangeset for help on using the changeset viewer.