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 [
|
return [
|
||||||
'name' => 'Cite',
|
'name' => 'Cite',
|
||||||
'domProcessors' => [
|
'domProcessors' => [
|
||||||
'wt2htmlPostProcessor' => RefProcessor::class,
|
RefProcessor::class,
|
||||||
'html2wtPreProcessor' => [ self::class, 'html2wtPreProcessor' ],
|
|
||||||
],
|
],
|
||||||
'tags' => [
|
'tags' => [
|
||||||
[
|
[
|
||||||
|
|
|
@ -4,35 +4,26 @@ declare( strict_types = 1 );
|
||||||
namespace Wikimedia\Parsoid\Ext\Cite;
|
namespace Wikimedia\Parsoid\Ext\Cite;
|
||||||
|
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
|
use Wikimedia\Parsoid\Ext\DOMProcessor;
|
||||||
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
|
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wt -> html DOM PostProcessor
|
* wt -> html DOM PostProcessor
|
||||||
*/
|
*/
|
||||||
class RefProcessor {
|
class RefProcessor extends DOMProcessor {
|
||||||
/** @var ParsoidExtensionAPI Provides post-processing support */
|
|
||||||
private $extApi;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ParsoidExtensionAPI $extApi
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function __construct( ParsoidExtensionAPI $extApi ) {
|
public function wtPostprocess(
|
||||||
$this->extApi = $extApi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ParsoidExtensionAPI $extApi
|
|
||||||
* @param DOMElement $body
|
|
||||||
* @param array $options
|
|
||||||
* @param bool $atTopLevel
|
|
||||||
*/
|
|
||||||
public function run(
|
|
||||||
ParsoidExtensionAPI $extApi, DOMElement $body, array $options, bool $atTopLevel
|
ParsoidExtensionAPI $extApi, DOMElement $body, array $options, bool $atTopLevel
|
||||||
): void {
|
): void {
|
||||||
if ( $atTopLevel ) {
|
if ( $atTopLevel ) {
|
||||||
$refsData = new ReferencesData();
|
$refsData = new ReferencesData();
|
||||||
References::processRefs( $this->extApi, $refsData, $body );
|
References::processRefs( $extApi, $refsData, $body );
|
||||||
References::insertMissingReferencesIntoDOM( $this->extApi, $refsData, $body );
|
References::insertMissingReferencesIntoDOM( $extApi, $refsData, $body );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: should implement an htmlPreprocess method as well.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue