Skip to content

Commit

Permalink
Update the method for stripping unnecessary elements added by DOMDocu…
Browse files Browse the repository at this point in the history
…ment. See #63
  • Loading branch information
bradyvercher committed Jan 16, 2020
1 parent 5d910ff commit f54337c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions includes/class-gistpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,6 @@ public function get_gist_html( $url, array $args ) {
$this->debug_log( '<strong>' . __( 'Raw Key (Transient & Post Meta):', 'gistpress' ) . '</strong> ' . $raw_key, $shortcode_hash );
$this->debug_log( '<strong>' . __( 'Processed Output Key (Transient):', 'gistpress' ) . '</strong> ' . $transient_key, $shortcode_hash );

// Strip unnecessary elements from HTML output.
$html = preg_replace( '/^<!DOCTYPE.+?>/i', '', str_ireplace( array( '<html>', '</html>', '<body>', '</body>' ), '', $html ) );

return $html;
}

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

$dom = new DOMDocument();
$dom->loadHTML( $html );
$dom->loadHTML( $html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED );

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

Expand Down

0 comments on commit f54337c

Please sign in to comment.