mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-20 18:42:41 +00:00
Merge "Normalize ref html before comparison"
This commit is contained in:
commit
e23ae99870
|
@ -10,6 +10,7 @@ use Cite\Cite;
|
||||||
use Cite\MarkSymbolRenderer;
|
use Cite\MarkSymbolRenderer;
|
||||||
use Closure;
|
use Closure;
|
||||||
use MediaWiki\Config\Config;
|
use MediaWiki\Config\Config;
|
||||||
|
use MediaWiki\HtmlHelper;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
use Wikimedia\Message\MessageValue;
|
use Wikimedia\Message\MessageValue;
|
||||||
|
@ -27,6 +28,7 @@ use Wikimedia\Parsoid\NodeData\DataMw;
|
||||||
use Wikimedia\Parsoid\NodeData\DataMwError;
|
use Wikimedia\Parsoid\NodeData\DataMwError;
|
||||||
use Wikimedia\Parsoid\NodeData\DataParsoid;
|
use Wikimedia\Parsoid\NodeData\DataParsoid;
|
||||||
use Wikimedia\Parsoid\Utils\DOMCompat;
|
use Wikimedia\Parsoid\Utils\DOMCompat;
|
||||||
|
use Wikimedia\RemexHtml\Serializer\SerializerNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @license GPL-2.0-or-later
|
* @license GPL-2.0-or-later
|
||||||
|
@ -226,7 +228,7 @@ class References extends ExtensionTagHandler {
|
||||||
// Ideally, we should strip the mw:Cite/Follow wrappers before comparing
|
// Ideally, we should strip the mw:Cite/Follow wrappers before comparing
|
||||||
// But, we are going to ignore this edge case as not worth the complexity.
|
// But, we are going to ignore this edge case as not worth the complexity.
|
||||||
$html = $extApi->domToHtml( $c, true, false );
|
$html = $extApi->domToHtml( $c, true, false );
|
||||||
$contentDiffers = ( $html !== $ref->cachedHtml );
|
$contentDiffers = ( $this->normalizeRef( $html ) !== $this->normalizeRef( $ref->cachedHtml ) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( $refsData->inReferencesContent() ) {
|
if ( $refsData->inReferencesContent() ) {
|
||||||
|
@ -878,4 +880,17 @@ class References extends ExtensionTagHandler {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function normalizeRef( string $s ): string {
|
||||||
|
return HtmlHelper::modifyElements( $s,
|
||||||
|
static function ( SerializerNode $node ): bool {
|
||||||
|
return isset( $node->attrs['data-parsoid'] ) || isset( $node->attrs['about'] );
|
||||||
|
},
|
||||||
|
static function ( SerializerNode $node ): SerializerNode {
|
||||||
|
unset( $node->attrs['data-parsoid'] );
|
||||||
|
unset( $node->attrs['about'] );
|
||||||
|
return $node;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue