6use Wikimedia\Parsoid\Core\PageBundle;
19 public const PARSOID_PAGE_BUNDLE_KEY =
'parsoid-page-bundle';
25 private function __construct() {
44 PageBundle $pageBundle, ?
ParserOutput $parserOutput =
null
46 if ( $parserOutput === null ) {
49 $parserOutput->setText( $pageBundle->html );
51 $parserOutput->setExtensionData(
52 self::PARSOID_PAGE_BUNDLE_KEY,
54 'parsoid' => $pageBundle->parsoid,
55 'mw' => $pageBundle->mw,
56 'version' => $pageBundle->version,
57 'headers' => $pageBundle->headers,
58 'contentmodel' => $pageBundle->contentmodel,
73 $pageBundleData = $parserOutput->
getExtensionData( self::PARSOID_PAGE_BUNDLE_KEY );
74 return new PageBundle(
76 $pageBundleData[
'parsoid'] ?? [],
77 $pageBundleData[
'mw'] ?? [],
80 $pageBundleData[
'version'] ??
'0.0.0',
81 $pageBundleData[
'headers'] ?? [],
82 $pageBundleData[
'contentmodel'] ??
null
getExtensionData()
Get the extension data as: augmentor name => data.
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Provides methods for conversion between PageBundle and ParserOutput TODO: Convert to a trait once we ...
static pageBundleFromParserOutput(ParserOutput $parserOutput)
Returns a Parsoid PageBundle equivalent to the given ParserOutput.
static parserOutputFromPageBundle(PageBundle $pageBundle, ?ParserOutput $parserOutput=null)
Creates a ParserOutput object containing the relevant data from the given PageBundle object.
getRawText()
Get the cacheable text with <mw:editsection> markers still in it.