WordPress.org

Make WordPress Core

Ticket #14674: 14674.diff

File 14674.diff, 1.4 KB (added by solarissmoke, 5 years ago)

HR's are a special case of block level element because they self-close

  • wp-includes/formatting.php

     
    188188        $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; 
    189189        $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); 
    190190        $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee); 
     191        $pee = str_replace('<hr />', "\n\n<hr />\n\n", $pee);   // hr's are block-level and self-closing 
    191192        $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines 
    192193        if ( strpos($pee, '<object') !== false ) { 
    193194                $pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed 
     
    207208        $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee); 
    208209        $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee); 
    209210        $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); 
     211 
    210212        if ($br) { 
    211213                $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee); 
    212214                $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks