| 565 | | return $html; |
| | 566 | $pre = array(); |
| | 567 | $tokens = array(); |
| | 568 | if ( class_exists( 'DOMDocument' ) ) { |
| | 569 | $token = '__PRE__'; |
| | 570 | $replace = array(); |
| | 571 | $dom = new DOMDocument(); |
| | 572 | $dom->loadHTML( $html ); |
| | 573 | $tags = $dom->getElementsByTagName( 'pre' ); |
| | 574 | foreach ( $tags as $i => $tag ) { |
| | 575 | $tag_html = $dom->saveHTML( $tag ); |
| | 576 | $tag_token = $token . $i; |
| | 577 | $replace[ $tag_token ] = $tag_html; |
| | 578 | $html = str_replace( $tag_html, $tag_token, $html ); |
| | 579 | } |
| | 580 | $pre = array_values( $replace ); |
| | 581 | $tokens = array_keys( $replace ); |
| | 582 | } |
| | 583 | |
| | 584 | $stripped = str_replace( array( "\r\n", "\n" ), '', $html ); |
| | 585 | return str_replace( $tokens, $pre, $stripped ); |