- private function _strip_newlines( $html, $data, $url ) {
- if ( false !== strpos( $html, "\n" ) )
- $html = str_replace( array( "\r\n", "\n" ), '', $html );
+ public function _strip_newlines( $html, $data, $url ) {
+ if ( false === strpos( $html, "\n" ) ) {
+ return $html;
+ }
+
+ $count = 1;
+ $found = array();
+ $token = '__PRE__';
+ $search = array( "\t", "\n", "\r", ' ' );
+ $replace = array( '__TAB__', '__NL__', '__CR__', '__SPACE__' );
+ $tokenized = str_replace( $search, $replace, $html );
+
+ preg_match_all( '#(<pre[^>]*>.+?</pre>)#i', $tokenized, $matches, PREG_SET_ORDER );
+ foreach ( $matches as $i => $match ) {
+ $tag_html = str_replace( $replace, $search, $match[0] );
+ $tag_token = $token . $i;