Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
RefProcessor
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 wtPostprocess
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 htmlPreprocess
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2declare( strict_types = 1 );
3
4namespace Cite\Parsoid;
5
6use MediaWiki\Config\Config;
7use Wikimedia\Parsoid\DOM\Element;
8use Wikimedia\Parsoid\DOM\Node;
9use Wikimedia\Parsoid\Ext\DOMProcessor;
10use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
11
12/**
13 * wt -> html DOM PostProcessor
14 * @license GPL-2.0-or-later
15 */
16class RefProcessor extends DOMProcessor {
17    private Config $mainConfig;
18
19    public function __construct( Config $mainConfig ) {
20        $this->mainConfig = $mainConfig;
21    }
22
23    /**
24     * @inheritDoc
25     */
26    public function wtPostprocess(
27        ParsoidExtensionAPI $extApi, Node $node, array $options
28    ): void {
29        $refsData = new ReferencesData();
30        $references = new References( $this->mainConfig );
31        $references->processRefs( $extApi, $refsData, $node );
32        $references->insertMissingReferencesIntoDOM( $extApi, $refsData, $node );
33        if ( $refsData->embeddedErrors ) {
34            $references->addEmbeddedErrors( $extApi, $refsData, $node );
35        }
36    }
37
38    /**
39     * html -> wt DOM PreProcessor
40     *
41     * Nothing to do right now.
42     *
43     * But, for example, as part of some future functionality, this could be used to
44     * reconstitute page-level information from local annotations left behind by editing clients.
45     */
46    public function htmlPreprocess( ParsoidExtensionAPI $extApi, Element $root ): void {
47        // TODO
48    }
49}