| 224 | | $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); |
| 225 | | $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee); |
| 226 | | $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines |
| 227 | | if ( strpos($pee, '<object') !== false ) { |
| 228 | | $pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed |
| 229 | | $pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee); |
| | 224 | $text = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $text); |
| | 225 | $text = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $text); |
| | 226 | $text = str_replace(array("\r\n", "\r"), "\n", $text); // cross-platform newlines |
| | 227 | if ( strpos($text, '<object') !== false ) { |
| | 228 | $text = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $text); // no paragraph inside object/embed |
| | 229 | $text = preg_replace('|\s*</embed>\s*|', '</embed>', $text); |
| 233 | | $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY); |
| 234 | | $pee = ''; |
| 235 | | foreach ( $pees as $tinkle ) |
| 236 | | $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n"; |
| 237 | | $pee = preg_replace('|<p>\s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace |
| 238 | | $pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee); |
| 239 | | $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag |
| 240 | | $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists |
| 241 | | $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee); |
| 242 | | $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee); |
| 243 | | $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee); |
| 244 | | $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); |
| | 233 | $texts = preg_split('/\n\s*\n/', $text, -1, PREG_SPLIT_NO_EMPTY); |
| | 234 | $text = ''; |
| | 235 | foreach ( $texts as $paragraph ) |
| | 236 | $text .= '<p>' . trim($paragraph, "\n") . "</p>\n"; |
| | 237 | $text = preg_replace('|<p>\s*</p>|', '', $text); // under certain strange conditions it could create a P of entirely whitespace |
| | 238 | $text = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $text); |
| | 239 | $text = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $text); // don't wrap blocks |
| | 240 | $text = preg_replace("|<p>(<li.+?)</p>|", "$1", $text); // problem with nested lists |
| | 241 | $text = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $text); |
| | 242 | $text = str_replace('</blockquote></p>', '</p></blockquote>', $text); |
| | 243 | $text = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $text); |
| | 244 | $text = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $text); |
| 246 | | $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee); |
| 247 | | $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks |
| 248 | | $pee = str_replace('<WPPreserveNewline />', "\n", $pee); |
| | 246 | $text = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $text); |
| | 247 | $text = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $text); // optionally make line breaks |
| | 248 | $text = str_replace('<WPPreserveNewline />', "\n", $text); |
| 250 | | $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee); |
| 251 | | $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee); |
| 252 | | $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); |
| | 250 | $text = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $text); |
| | 251 | $text = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $text); |
| | 252 | $text = preg_replace( "|\n</p>$|", '</p>', $text ); |