| 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\Node; |
| 8 |
use Wikimedia\Parsoid\Wt2Html\Wt2HtmlDOMProcessor; |
| 9 |
|
| 10 |
class WrapSections implements Wt2HtmlDOMProcessor { |
| 11 |
|
| 12 |
/** |
| 13 |
* DOM Postprocessor entry function to walk DOM rooted at $root |
| 14 |
* and add <section> wrappers as necessary. |
| 15 |
* Implements the algorithm documented @ mw:Parsing/Notes/Section_Wrapping |
| 16 |
* |
| 17 |
* @inheritDoc |
| 18 |
*/ |
| 19 |
public function run( |
| 20 |
Env $env, Node $root, array $options = [], bool $atTopLevel = false |
| 21 |
): void { |
| 22 |
if ( !$env->getWrapSections() ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
$state = new WrapSectionsState( |
| 27 |
$env, |
| 28 |
$options['frame'], |
| 29 |
$root |
| 30 |
); |
| 31 |
$state->run(); |
| 32 |
} |
| 33 |
} |