MediaWiki master
MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter Class Reference

Provides methods for conversion between HtmlPageBundle and ParserOutput. More...

Public Member Functions

 __construct (private readonly SiteConfig $siteConfig, private readonly ?RevisionLookup $revisionLookup, private readonly ?LanguageFactory $languageFactory,)
 htmlPageBundleFromParserOutput (ParserOutput $parserOutput, bool $bodyOnly=false,)
 Returns a Parsoid HtmlPageBundle equivalent to the given ParserOutput.
 parserOutputFromPageBundle (HtmlPageBundle $pageBundle, bool $isParsoidContent, ?ParserOutput $originalParserOutput=null, ParsoidLinkTarget|PageReference|null $title=null,)
 Creates a ParserOutput object containing the relevant data from the given HtmlPageBundle object.

Detailed Description

Provides methods for conversion between HtmlPageBundle and ParserOutput.

ParserOutput typically contains only the article content HTML (ie, without <body> tags), while a HtmlPageBundle can contain an entire document including <html> wrapper, metadata in the <head>, and article content inside a <body> tag.

Since
1.40
Access: internal

Definition at line 44 of file PageBundleParserOutputConverter.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter::__construct ( private readonly SiteConfig $siteConfig,
private readonly ?RevisionLookup $revisionLookup,
private readonly ?LanguageFactory $languageFactory )

Definition at line 46 of file PageBundleParserOutputConverter.php.

Member Function Documentation

◆ htmlPageBundleFromParserOutput()

MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter::htmlPageBundleFromParserOutput ( ParserOutput $parserOutput,
bool $bodyOnly = false )

Returns a Parsoid HtmlPageBundle equivalent to the given ParserOutput.

Parameters
ParserOutput$parserOutput
bool$bodyOnlyIf false, returns a full document with metadata in the <head>. If true, the html section of the PageBundle returns the inner HTML of the <body> element only.
Returns
HtmlPageBundle

Definition at line 122 of file PageBundleParserOutputConverter.php.

◆ parserOutputFromPageBundle()

MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter::parserOutputFromPageBundle ( HtmlPageBundle $pageBundle,
bool $isParsoidContent,
?ParserOutput $originalParserOutput = null,
ParsoidLinkTarget|PageReference|null $title = null )

Creates a ParserOutput object containing the relevant data from the given HtmlPageBundle object.

We need to inject data-parsoid and other properties into the parser output object for caching, so we can use it for VE edits and transformations.

Parameters
HtmlPageBundle$pageBundle
bool$isParsoidContentTrue if the content of this $pageBundle was generated by Parsoid; false if it was generated by the legacy parser.
?ParserOutput$originalParserOutputAny non-parsoid metadata from $originalParserOutput will be copied into the new ParserOutput object.
ParsoidLinkTarget | PageReference | null$titleThe given title will be copied into the new ParserOutput object.
Returns
ParserOutput

Definition at line 72 of file PageBundleParserOutputConverter.php.

References MediaWiki\Parser\ContentHolder\createFromPageBundle().


The documentation for this class was generated from the following file: