Skip to content

Commit f54337c

Browse files
committed
Update the method for stripping unnecessary elements added by DOMDocument. See #63
1 parent 5d910ff commit f54337c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

includes/class-gistpress.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,6 @@ public function get_gist_html( $url, array $args ) {
412412
$this->debug_log( '<strong>' . __( 'Raw Key (Transient & Post Meta):', 'gistpress' ) . '</strong> ' . $raw_key, $shortcode_hash );
413413
$this->debug_log( '<strong>' . __( 'Processed Output Key (Transient):', 'gistpress' ) . '</strong> ' . $transient_key, $shortcode_hash );
414414

415-
// Strip unnecessary elements from HTML output.
416-
$html = preg_replace( '/^<!DOCTYPE.+?>/i', '', str_ireplace( array( '<html>', '</html>', '<body>', '</body>' ), '', $html ) );
417-
418415
return $html;
419416
}
420417

@@ -466,7 +463,7 @@ public function process_gist_html( $html, array $args ) {
466463
$html = '<?xml encoding="utf-8" ?>' . $html;
467464

468465
$dom = new DOMDocument();
469-
$dom->loadHTML( $html );
466+
$dom->loadHTML( $html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED );
470467

471468
$lines = $dom->getElementsByTagName( 'tr' );
472469

0 commit comments

Comments
 (0)