Revert "Normalize ref html before comparison"

This reverts commit 91316d49c2.

Reason for revert: Caused T380977 when Remex was given math
content to normalize.

Change-Id: I6d7585a990322b5c8e2a6886b9cd05a556c501ad
This commit is contained in:
C. Scott Ananian 2024-11-27 17:04:56 +00:00 committed by Gerrit Code Review
parent 91316d49c2
commit 4ecb325052

View file

@ -10,7 +10,6 @@ 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;
@ -28,7 +27,6 @@ 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
@ -228,7 +226,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 = ( $this->normalizeRef( $html ) !== $this->normalizeRef( $ref->cachedHtml ) ); $contentDiffers = ( $html !== $ref->cachedHtml );
} }
} else { } else {
if ( $refsData->inReferencesContent() ) { if ( $refsData->inReferencesContent() ) {
@ -880,17 +878,4 @@ 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;
}
);
}
} }