2019-04-03 17:16:56 +00:00
|
|
|
<?php
|
2019-05-25 22:24:47 +00:00
|
|
|
declare( strict_types = 1 );
|
2019-04-03 17:16:56 +00:00
|
|
|
|
2020-02-03 18:52:06 +00:00
|
|
|
namespace Wikimedia\Parsoid\Ext\Cite;
|
2019-05-25 22:24:47 +00:00
|
|
|
|
|
|
|
use DOMElement;
|
2020-02-03 18:52:06 +00:00
|
|
|
use Wikimedia\Parsoid\Config\Env;
|
2020-01-17 13:12:15 +00:00
|
|
|
use Wikimedia\Parsoid\Config\ParsoidExtensionAPI;
|
2019-04-03 17:16:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* wt -> html DOM PostProcessor
|
|
|
|
*/
|
|
|
|
class RefProcessor {
|
2020-01-17 13:12:15 +00:00
|
|
|
/** @var ParsoidExtensionAPI Provides post-processing support */
|
|
|
|
private $extApi;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ParsoidExtensionAPI $extApi
|
|
|
|
*/
|
|
|
|
public function __construct( ParsoidExtensionAPI $extApi ) {
|
|
|
|
$this->extApi = $extApi;
|
|
|
|
}
|
2019-05-25 22:24:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param DOMElement $body
|
|
|
|
* @param Env $env
|
|
|
|
* @param array $options
|
|
|
|
* @param bool $atTopLevel
|
|
|
|
*/
|
|
|
|
public function run(
|
|
|
|
DOMElement $body, Env $env, array $options = [], bool $atTopLevel = false
|
|
|
|
): void {
|
2019-04-03 17:16:56 +00:00
|
|
|
if ( $atTopLevel ) {
|
|
|
|
$refsData = new ReferencesData( $env );
|
2020-01-17 13:12:15 +00:00
|
|
|
References::processRefs( $this->extApi, $refsData, $body );
|
2019-04-03 17:16:56 +00:00
|
|
|
References::insertMissingReferencesIntoDOM( $refsData, $body );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|