6use Wikimedia\Parsoid\Core\PageBundle;
19 public const PARSOID_PAGE_BUNDLE_KEY =
'parsoid-page-bundle';
25 private function __construct() {
43 PageBundle $pageBundle, ?
ParserOutput $originalParserOutput =
null
47 if ( $originalParserOutput ) {
49 $parserOutput->mergeTrackingMetaDataFrom( $originalParserOutput );
50 $parserOutput->mergeInternalMetaDataFrom( $originalParserOutput );
53 $parserOutput->setExtensionData(
54 self::PARSOID_PAGE_BUNDLE_KEY,
56 'parsoid' => $pageBundle->parsoid,
57 'mw' => $pageBundle->mw,
58 'version' => $pageBundle->version,
59 'headers' => $pageBundle->headers,
60 'contentmodel' => $pageBundle->contentmodel,
75 $pageBundleData = $parserOutput->
getExtensionData( self::PARSOID_PAGE_BUNDLE_KEY );
76 return new PageBundle(
78 $pageBundleData[
'parsoid'] ?? [],
79 $pageBundleData[
'mw'] ?? [],
82 $pageBundleData[
'version'] ??
'0.0.0',
83 $pageBundleData[
'headers'] ?? [],
84 $pageBundleData[
'contentmodel'] ??
null
89 return $parserOutput->
getExtensionData( self::PARSOID_PAGE_BUNDLE_KEY ) !==
null;
getExtensionData()
Get the extension data as: augmentor name => data.
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.
Rendered output of a wiki page, as parsed from wikitext.
mergeHtmlMetaDataFrom(ParserOutput $source)
Merges HTML metadata such as head items, JS config vars, and HTTP cache control info from $source int...
getExtensionData( $key)
Gets extensions data previously attached to this ParserOutput using setExtensionData().
getRawText()
Get the cacheable text with <mw:editsection> markers still in it.