[wp-trac] [WordPress Trac] #15657: wp_strip_all_tags causes paragraphs to run together
WordPress Trac
wp-trac at lists.automattic.com
Mon Dec 26 22:35:03 UTC 2011
#15657: wp_strip_all_tags causes paragraphs to run together
-------------------------------------------------+-------------------------
Reporter: jwz | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
Component: Formatting | Release
Severity: normal | Version: 2.9
Keywords: has-patch 3.2-early needs-unit- | Resolution:
tests |
-------------------------------------------------+-------------------------
Comment (by jwz):
Replying to [comment:4 trepmal]:
Right you are, I think this is a better version (compress incoming
whitespace, don't leave beginning- and end-of-line spaces when emitting
newlines):
{{{
function wp_strip_all_tags_patched($string, $remove_breaks = false) {
$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '',
$string );
$string = preg_replace( '@ *</?\s*(P|UL|OL|DL|BLOCKQUOTE)\b[^>]*?>
*@si', "\n\n", $string );
$string = preg_replace( '@ *<(BR|DIV|LI|DT|DD|TR|TD|H\d)\b[^>]*?>
*@si', "\n", $string );
$string = preg_replace( "@\n\n\n+ at si", "\n\n", $string );
$string = strip_tags( $string );
if ( $remove_breaks )
$string = preg_replace('/[\r\n\t ]+/', ' ', $string);
return trim( $string );
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15657#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list