Parsoid
A bidirectional parser between wikitext and HTML5
Loading...
Searching...
No Matches
Wikimedia\Parsoid\Core\PageBundle Class Reference

A page bundle stores an HTML string with separated data-parsoid and (optionally) data-mw content. More...

+ Inheritance diagram for Wikimedia\Parsoid\Core\PageBundle:
+ Collaboration diagram for Wikimedia\Parsoid\Core\PageBundle:

Public Member Functions

 __construct (string $html, ?array $parsoid=null, ?array $mw=null, ?string $version=null, ?array $headers=null, ?string $contentmodel=null)
 
 validate (string $contentVersion, ?string &$errorMessage=null)
 Check if this pagebundle is valid.
 
 responseData ()
 
 toSingleDocumentHtml (array $options=[])
 Convert this PageBundle to "single document" form, where page bundle information is embedded in the <head> of the document.
 
 toInlineAttributeHtml (array $options=[])
 Convert this PageBundle to "inline attribute" form, where page bundle information is represented as inline JSON-valued attributes.
 
 toJsonArray ()
 

Static Public Member Functions

static newEmpty (string $html, ?string $version=null, ?array $headers=null, ?string $contentmodel=null)
 
static fromDomPageBundle (DomPageBundle $dpb, array $options=[])
 Convert a DomPageBundle to a PageBundle.
 
static newFromJsonArray (array $json)
 

Public Attributes

string $html
 The document, as an HTML string.
 
 $parsoid
 
 $mw
 
 $version
 
 $headers
 
 $contentmodel
 

Detailed Description

A page bundle stores an HTML string with separated data-parsoid and (optionally) data-mw content.

The data-parsoid and data-mw content is indexed by the id attributes on individual nodes. This content needs to be loaded before the data-parsoid and/or data-mw information can be used.

Note that the parsoid/mw properties of the page bundle are in "serialized array" form; that is, they are flat arrays appropriate for json-encoding and do not contain DataParsoid or DataMw objects.

See DomPageBundle for a similar structure used where the HTML string has been parsed into a DOM.

Member Function Documentation

◆ fromDomPageBundle()

static Wikimedia\Parsoid\Core\PageBundle::fromDomPageBundle ( DomPageBundle $dpb,
array $options = [] )
static

Convert a DomPageBundle to a PageBundle.

This serializes the DOM from the DomPageBundle, with the given $options. The options can also provide defaults for content version, headers, content model, and offsetType if they weren't already set in the DomPageBundle.

Parameters
DomPageBundle$dpb
array$optionsXMLSerializer options
Returns
PageBundle

◆ responseData()

Wikimedia\Parsoid\Core\PageBundle::responseData ( )
Returns
array

◆ toInlineAttributeHtml()

Wikimedia\Parsoid\Core\PageBundle::toInlineAttributeHtml ( array $options = [])

Convert this PageBundle to "inline attribute" form, where page bundle information is represented as inline JSON-valued attributes.

Parameters
array$optionsXMLSerializer options
Returns
string an HTML string

◆ toSingleDocumentHtml()

Wikimedia\Parsoid\Core\PageBundle::toSingleDocumentHtml ( array $options = [])

Convert this PageBundle to "single document" form, where page bundle information is embedded in the <head> of the document.

Parameters
array$optionsXMLSerializer options
Returns
string an HTML string

◆ validate()

Wikimedia\Parsoid\Core\PageBundle::validate ( string $contentVersion,
?string & $errorMessage = null )

Check if this pagebundle is valid.

Parameters
string$contentVersionDocument content version to validate against.
?string&$errorMessageError message will be returned here.
Returns
bool

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