WordPress.org

Make WordPress Core

Ticket #3935: 3935.wpautop-fix.patch

File 3935.wpautop-fix.patch, 2.0 KB (added by DD32, 15 years ago)

wpautop patch

  • wp-includes/formatting.php

     
    5656        $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
    5757        // Space things out a little
    5858        $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|script|object|input|param|p|h[1-6])';
     59        $allblocksnop = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|script|object|input|param|h[1-6])';
    5960        $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
    6061        $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
    6162        $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
     
    6869        $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
    6970        $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
    7071        $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
    71         $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
    72         $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
     72        $pee = preg_replace('!<p>\s*(</?' . $allblocksnop . '[^>]*>)!', "$1", $pee);
     73        $pee = preg_replace('!(</?' . $allblocksnop . '[^>]*>)\s*</p>!', "$1", $pee);
     74        $pee = preg_replace('!(<p>\s*</p>(</?' . $allblocksnop . '[^>]*>))!', "$2", $pee);
    7375        if ($br) {
    7476                $pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee);
    7577                $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
     
    8082        if (strpos($pee, '<pre') !== false)
    8183                $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' ", $pee);
    8284        $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
    83 
    8485        return $pee;
    8586}
    8687