mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
All extension DOM processors should extend Ext\DOMProcessor
Change-Id: Ide9700747b3ecea9da59911c6eb342569be4c9b8
This commit is contained in:
parent
b4aefae357
commit
51c211047a
|
@ -17,8 +17,7 @@ class Cite implements ExtensionModule {
|
|||
return [
|
||||
'name' => 'Cite',
|
||||
'domProcessors' => [
|
||||
'wt2htmlPostProcessor' => RefProcessor::class,
|
||||
'html2wtPreProcessor' => [ self::class, 'html2wtPreProcessor' ],
|
||||
RefProcessor::class,
|
||||
],
|
||||
'tags' => [
|
||||
[
|
||||
|
|
|
@ -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.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue