8use Wikimedia\Parsoid\Core\PageBundle;
9use Wikimedia\Parsoid\DOM\Document;
10use Wikimedia\Parsoid\Mocks\MockEnv;
11use Wikimedia\Parsoid\Utils\ContentUtils;
12use Wikimedia\Parsoid\Utils\DOMCompat;
13use Wikimedia\Parsoid\Utils\DOMDataUtils;
14use Wikimedia\Parsoid\Utils\DOMUtils;
33 if ( $hasPageBundle ) {
36 PageBundle::apply( $doc, $pb );
37 DOMDataUtils::prepareDoc( $doc );
38 DOMDataUtils::visitAndLoadDataAttribs(
39 DOMCompat::getBody( $doc )
42 $doc = ContentUtils::createAndLoadDocument(
47 $doc = $this->
transformDOM( $doc, $po, $popts, $options );
50 if ( $hasPageBundle ) {
51 DOMDataUtils::visitAndStoreDataAttribs(
52 DOMCompat::getBody( $doc ),
54 'storeInPageBundle' =>
true,
55 'env' =>
new MockEnv( [] ),
58 $pb = DOMDataUtils::getPageBundle( $doc );
62 $text = ContentUtils::toXML( DOMCompat::getBody( $doc ), [
66 $text = ContentUtils::ppToXML( DOMCompat::getBody( $doc ), [
OutputTransformStages that modify the content as a HTML DOM tree.
transformDOM(Document $dom, ParserOutput $po, ?ParserOptions $popts, array &$options)
Applies the transformation to a DOM document.
transform(ParserOutput $po, ?ParserOptions $popts, array &$options)
Transforms the input ParserOutput into the returned ParserOutput.The returned ParserOutput can explic...
Provides methods for conversion between PageBundle and ParserOutput TODO: Convert to a trait once we ...
static hasPageBundle(ParserOutput $parserOutput)
static pageBundleFromParserOutput(ParserOutput $parserOutput)
Returns a Parsoid PageBundle equivalent to the given ParserOutput.
static parserOutputFromPageBundle(PageBundle $pageBundle, ?ParserOutput $originalParserOutput=null)
Creates a ParserOutput object containing the relevant data from the given PageBundle object.
Set options of the Parser.