mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-20 10:40:54 +00:00
d0a9c42c98
* Remove use of $env from ReferencesData and RefGroup by providing high-level helpers in ParsoidExtensionAPI. - Given a fragment id, provide helpers to fetch fragment DOM or fragment HTML - Fetch the URI for the current page (being parsed) * There is still a lot of subtle knowledge Cite has about how data-parsoid and data-mw attributes are held off to the side in a bag and all the pp* and load/store manipulation of those attributes. It would be an interesting exercise to purge this implementation of those notions OR figure out high-level concepts that we document as being part of Parsoid reality that we'll forever support. Bug: T242746 Change-Id: I29ff154f2f17123b9756dfd2f3b422f0b30222b1
39 lines
921 B
PHP
39 lines
921 B
PHP
<?php
|
|
declare( strict_types = 1 );
|
|
|
|
namespace Wikimedia\Parsoid\Ext\Cite;
|
|
|
|
use DOMElement;
|
|
use Wikimedia\Parsoid\Config\ParsoidExtensionAPI;
|
|
|
|
/**
|
|
* wt -> html DOM PostProcessor
|
|
*/
|
|
class RefProcessor {
|
|
/** @var ParsoidExtensionAPI Provides post-processing support */
|
|
private $extApi;
|
|
|
|
/**
|
|
* @param ParsoidExtensionAPI $extApi
|
|
*/
|
|
public function __construct( ParsoidExtensionAPI $extApi ) {
|
|
$this->extApi = $extApi;
|
|
}
|
|
|
|
/**
|
|
* @param DOMElement $body
|
|
* @param mixed $unused unused Env object FIXME: stop passing this through?
|
|
* @param array $options
|
|
* @param bool $atTopLevel
|
|
*/
|
|
public function run(
|
|
DOMElement $body, $unused, array $options = [], bool $atTopLevel = false
|
|
): void {
|
|
if ( $atTopLevel ) {
|
|
$refsData = new ReferencesData();
|
|
References::processRefs( $this->extApi, $refsData, $body );
|
|
References::insertMissingReferencesIntoDOM( $this->extApi, $refsData, $body );
|
|
}
|
|
}
|
|
}
|