Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ProcessEmbeddedDocs | |
0.00% |
0 / 28 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
processNode | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
12 | |||
run | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Wt2Html\DOM\Processors; |
5 | |
6 | use Wikimedia\Parsoid\Config\Env; |
7 | use Wikimedia\Parsoid\DOM\DocumentFragment; |
8 | use Wikimedia\Parsoid\DOM\Element; |
9 | use Wikimedia\Parsoid\DOM\Node; |
10 | use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; |
11 | use Wikimedia\Parsoid\Utils\ContentUtils; |
12 | use Wikimedia\Parsoid\Utils\PipelineUtils; |
13 | use Wikimedia\Parsoid\Wt2Html\Wt2HtmlDOMProcessor; |
14 | |
15 | /** |
16 | */ |
17 | class ProcessEmbeddedDocs implements Wt2HtmlDOMProcessor { |
18 | private Env $env; |
19 | private ParsoidExtensionAPI $extApi; |
20 | |
21 | private function processNode( Element $elt ): void { |
22 | ContentUtils::processAttributeEmbeddedDom( |
23 | $this->extApi, |
24 | $elt, |
25 | function ( DocumentFragment $df ) { |
26 | PipelineUtils::processContentInPipeline( |
27 | $this->env, |
28 | $this->env->topFrame, |
29 | $df, |
30 | [ |
31 | 'pipelineType' => 'fullparse-embedded-docs-dom-to-dom', |
32 | 'pipelineOpts' => [], |
33 | 'sol' => true |
34 | ], |
35 | ); |
36 | return true; // might have been changed. |
37 | } |
38 | ); |
39 | |
40 | $child = $elt->firstChild; |
41 | while ( $child ) { |
42 | if ( $child instanceof Element ) { |
43 | $this->processNode( $child ); |
44 | } |
45 | $child = $child->nextSibling; |
46 | } |
47 | } |
48 | |
49 | /** |
50 | * DOM Postprocessor entry function to walk DOM rooted at $root |
51 | * and convert the DSR offsets as needed. |
52 | * @see ConvertUtils::convertOffsets |
53 | * |
54 | * @inheritDoc |
55 | */ |
56 | public function run( |
57 | Env $env, Node $root, array $options = [], bool $atTopLevel = false |
58 | ): void { |
59 | $this->env = $env; |
60 | $this->extApi = new ParsoidExtensionAPI( $env ); |
61 | |
62 | $children = ( $root instanceof Element ) ? [ $root ] : $root->childNodes; |
63 | foreach ( $children as $child ) { |
64 | if ( $child instanceof Element ) { |
65 | $this->processNode( $child ); |
66 | } |
67 | } |
68 | } |
69 | } |