wfProfileIn( __METHOD__ );
if ( $this->doc ) {
+ wfProfileIn( __METHOD__ . '-dom' );
if ( $element !== null && !( $element instanceof DOMElement ) ) {
$element = $this->doc->getElementById( $element );
}
$body->appendChild( $element );
}
$html = $this->doc->saveHTML();
+ wfProfileOut( __METHOD__ . '-dom' );
+
+ wfProfileIn( __METHOD__ . '-fixes' );
$html = $this->fixLibXml( $html );
+ if ( wfIsWindows() ) {
+ // Cleanup for CRLF misprocessing of unknown origin on Windows.
+ //
+ // If this error continues in the future, please track it down in the
+ // XML code paths if possible and fix there.
+ $html = str_replace( ' ', '', $html );
+ }
+ $html = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', '', $html );
+ wfProfileOut( __METHOD__ . '-fixes' );
} else {
$html = $this->html;
}
- if ( wfIsWindows() ) {
- // Appears to be cleanup for CRLF misprocessing of unknown origin
- // when running server on Windows platform.
- //
- // If this error continues in the future, please track it down in the
- // XML code paths if possible and fix there.
- $html = str_replace( ' ', '', $html );
- }
- $html = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', '', $html );
$html = $this->onHtmlReady( $html );
+ wfProfileIn( __METHOD__ . '-flatten' );
if ( $this->elementsToFlatten ) {
$elements = implode( '|', $this->elementsToFlatten );
$html = preg_replace( "#</?($elements)\\b[^>]*>#is", '', $html );
}
+ wfProfileOut( __METHOD__ . '-flatten' );
wfProfileOut( __METHOD__ );
return $html;