From 20adb1d803a99be4c0bb7a770b40b4a5da409897 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Mon, 26 May 2003 11:44:05 +0000 Subject: [PATCH] Much improved (and faster!) autop. git-svn-id: http://svn.automattic.com/wordpress/trunk@106 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- b2-include/b2functions.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/b2-include/b2functions.php b/b2-include/b2functions.php index ee2048b910..71d9f13aca 100644 --- a/b2-include/b2functions.php +++ b/b2-include/b2functions.php @@ -99,19 +99,20 @@ function wptexturize($text) { } function wpautop($pee, $br=1) { - $pee = preg_replace("/(\r\n|\n|\r)/", "\n", $pee); // cross-platform newlines - $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates - $pee = preg_replace('/\n?(.+?)(\n\n|\z)/s', "

$1

\n", $pee); // make paragraphs, including one at the end - $pee = preg_replace('/

\s*(<(?:table|ol|ul|pre|select|form)>)/', "$1", $pee); - $pee = preg_replace('!()

!', "$1", $pee); - if ($br) $pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks - $pee = preg_replace('!()
!', "$1", $pee); - $pee = preg_replace('|

]*)>|i', "

", $pee); - $pee = str_replace('

', '

', $pee); - $pee = str_replace('

', '

', $pee); - $pee = preg_replace('#

\s*

#', '

', $pee); - $pee = preg_replace('/&[^#](?![a-z]*;)/', '&', $pee); - return $pee; + $pee = preg_replace('|
\s*
|', "\n\n", $pee); + $pee = preg_replace("/(\r\n|\n|\r)/", "\n", $pee); // cross-platform newlines + $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates + $pee = preg_replace('/\n?(.+?)(\n\n|\z)/s', "

$1

\n", $pee); // make paragraphs, including one at the end + $pee = str_replace('

', '

', $pee); + $pee = str_replace('

', '

', $pee); + $pee = str_replace('

', '

', $pee); + $pee = preg_replace('!

\s*()!', "$1", $pee); + $pee = preg_replace('!()\s*

!', "$1", $pee); + if ($br) $pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks + $pee = preg_replace('!()
!', "$1", $pee); + $pee = preg_replace('|

]*)>|i', "

", $pee); + $pee = str_replace('

', '

', $pee); + return $pee; } function autobrize($content) {