Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions HtmlDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class HtmlDiff {
private $specialCaseClosingTags = array( "</strong>", "</b>", "</i>", "</big>", "</small>", "</u>", "</sub>", "</sup>", "</strike>", "</s>", '</p>' );

public function __construct( $oldText, $newText, $encoding = 'UTF-8' ) {
$this->oldText = $this->purifyHtml( trim( $oldText ) );
$this->newText = $this->purifyHtml( trim( $newText ) );
$this->oldText = trim( $oldText );
$this->newText = trim( $newText );
$this->encoding = $encoding;
$this->content = '';
}
Expand All @@ -31,28 +31,28 @@ public function getDifference() {
return $this->content;
}

private function getStringBetween( $str, $start, $end ) {
$expStr = explode( $start, $str, 2 );
if( count( $expStr ) > 1 ) {
$expStr = explode( $end, $expStr[ 1 ] );
if( count( $expStr ) > 1 ) {
array_pop( $expStr );
return implode( $end, $expStr );
}
}
return '';
}

private function purifyHtml( $html, $tags = null ) {
if( class_exists( 'Tidy' ) && false ) {
$config = array( 'output-xhtml' => true, 'indent' => false );
$tidy = new tidy;
$tidy->parseString( $html, $config, 'utf8' );
$html = ( string )$tidy;
return $this->getStringBetween( $html, '<body>' );
}
return $html;
}
// private function getStringBetween( $str, $start, $end ) {
// $expStr = explode( $start, $str, 2 );
// if( count( $expStr ) > 1 ) {
// $expStr = explode( $end, $expStr[ 1 ] );
// if( count( $expStr ) > 1 ) {
// array_pop( $expStr );
// return implode( $end, $expStr );
// }
// }
// return '';
// }

// private function purifyHtml( $html, $tags = null ) {
// if( class_exists( 'Tidy' ) && false ) {
// $config = array( 'output-xhtml' => true, 'indent' => false );
// $tidy = new tidy;
// $tidy->parseString( $html, $config, 'utf8' );
// $html = ( string )$tidy;
// return $this->getStringBetween( $html, '<body>' );
// }
// return $html;
// }

public function build() {
$this->SplitInputsToWords();
Expand Down