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
|
|
|
|
2020-09-21 18:22:54 +00:00
|
|
|
use DOMElement;
|
2020-07-28 21:35:18 +00:00
|
|
|
use DOMNode;
|
2020-04-21 23:22:30 +00:00
|
|
|
use Wikimedia\Parsoid\Ext\DOMProcessor;
|
2020-03-04 21:40:55 +00:00
|
|
|
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
|
2019-04-03 17:16:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* wt -> html DOM PostProcessor
|
|
|
|
*/
|
2020-04-21 23:22:30 +00:00
|
|
|
class RefProcessor extends DOMProcessor {
|
2020-01-17 13:12:15 +00:00
|
|
|
|
|
|
|
/**
|
2020-04-21 23:22:30 +00:00
|
|
|
* @inheritDoc
|
2020-01-17 13:12:15 +00:00
|
|
|
*/
|
2020-04-21 23:22:30 +00:00
|
|
|
public function wtPostprocess(
|
2020-07-28 21:35:18 +00:00
|
|
|
ParsoidExtensionAPI $extApi, DOMNode $node, array $options, bool $atTopLevel
|
2019-05-25 22:24:47 +00:00
|
|
|
): void {
|
2019-04-03 17:16:56 +00:00
|
|
|
if ( $atTopLevel ) {
|
2020-02-07 16:17:42 +00:00
|
|
|
$refsData = new ReferencesData();
|
2020-07-28 21:35:18 +00:00
|
|
|
References::processRefs( $extApi, $refsData, $node );
|
|
|
|
References::insertMissingReferencesIntoDOM( $extApi, $refsData, $node );
|
2020-11-05 16:53:34 +00:00
|
|
|
if ( count( $refsData->embeddedErrors ) > 0 ) {
|
|
|
|
References::addEmbeddedErrors( $extApi, $refsData, $node );
|
|
|
|
}
|
2019-04-03 17:16:56 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-21 23:22:30 +00:00
|
|
|
|
2020-09-21 18:22:54 +00:00
|
|
|
/**
|
|
|
|
* html -> wt DOM PreProcessor
|
|
|
|
*
|
|
|
|
* Nothing to do right now.
|
|
|
|
*
|
|
|
|
* But, for example, as part of some future functionality, this could be used to
|
|
|
|
* reconstitute page-level information from local annotations left behind by editing clients.
|
|
|
|
*
|
|
|
|
* @param ParsoidExtensionAPI $extApi
|
|
|
|
* @param DOMElement $root
|
|
|
|
*/
|
|
|
|
public function htmlPreprocess( ParsoidExtensionAPI $extApi, DOMElement $root ): void {
|
|
|
|
// TODO
|
|
|
|
}
|
2019-04-03 17:16:56 +00:00
|
|
|
}
|