All extension DOM processors should extend Ext\DOMProcessor

Change-Id: Ide9700747b3ecea9da59911c6eb342569be4c9b8
This commit is contained in:
C. Scott Ananian 2020-04-21 19:22:30 -04:00 committed by Subramanya Sastry
parent b4aefae357
commit 51c211047a
2 changed files with 9 additions and 19 deletions

View file

@ -17,8 +17,7 @@ class Cite implements ExtensionModule {
return [
'name' => 'Cite',
'domProcessors' => [
'wt2htmlPostProcessor' => RefProcessor::class,
'html2wtPreProcessor' => [ self::class, 'html2wtPreProcessor' ],
RefProcessor::class,
],
'tags' => [
[

View file

@ -4,35 +4,26 @@ declare( strict_types = 1 );
namespace Wikimedia\Parsoid\Ext\Cite;
use DOMElement;
use Wikimedia\Parsoid\Ext\DOMProcessor;
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
/**
* wt -> html DOM PostProcessor
*/
class RefProcessor {
/** @var ParsoidExtensionAPI Provides post-processing support */
private $extApi;
class RefProcessor extends DOMProcessor {
/**
* @param ParsoidExtensionAPI $extApi
* @inheritDoc
*/
public function __construct( ParsoidExtensionAPI $extApi ) {
$this->extApi = $extApi;
}
/**
* @param ParsoidExtensionAPI $extApi
* @param DOMElement $body
* @param array $options
* @param bool $atTopLevel
*/
public function run(
public function wtPostprocess(
ParsoidExtensionAPI $extApi, DOMElement $body, array $options, bool $atTopLevel
): void {
if ( $atTopLevel ) {
$refsData = new ReferencesData();
References::processRefs( $this->extApi, $refsData, $body );
References::insertMissingReferencesIntoDOM( $this->extApi, $refsData, $body );
References::processRefs( $extApi, $refsData, $body );
References::insertMissingReferencesIntoDOM( $extApi, $refsData, $body );
}
}
// FIXME: should implement an htmlPreprocess method as well.
}