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

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

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

Public Member Functions

 responseData ()
 
 toSingleDocumentHtml (array $options=[])
 Convert this HtmlPageBundle to "single document" form, where page bundle information is embedded in the <head> of the document.
 
 toInlineAttributeHtml (array $options=[], ?array &$fragments=null, ?SiteConfig $siteConfig=null)
 Convert this HtmlPageBundle to "inline attribute" form, where page bundle information is represented as inline JSON-valued attributes.
 
 toJsonArray ()
 
- Public Member Functions inherited from Wikimedia\Parsoid\Core\BasePageBundle
 validate (string $contentVersion, ?string &$errorMessage=null)
 Check if this pagebundle is valid.
 
 withHtml (string $html, array $fragments=[])
 Build an HtmlPageBundle by adding HTML string contents to this base page bundle.
 
 withDocument (Document $doc, array $fragments=[])
 Build an DomPageBundle by adding DOM contents to this base page bundle.
 
 toBasePageBundle ()
 Build a BasePageBundle with just the metadata from another page bundle.
 

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 an HtmlPageBundle.
 
static newFromJsonArray (array $json)
 

Detailed Description

An "HTML 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\HtmlPageBundle::fromDomPageBundle ( DomPageBundle $dpb,
array $options = [] )
static

Convert a DomPageBundle to an HtmlPageBundle.

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$optionsXHtmlSerializer options
Returns
self

◆ newFromJsonArray()

static Wikimedia\Parsoid\Core\HtmlPageBundle::newFromJsonArray ( array $json)
static

◆ responseData()

Wikimedia\Parsoid\Core\HtmlPageBundle::responseData ( )
Returns
array{contentmodel: string, html: array{headers: array, body: string}, data-parsoid: array{headers: array{content-type: string}, body: ?array{counter?: int, offsetType?: 'byte'|'char'|'ucs2', ids: array<string, array>}}, data-mw?: array{headers: array{content-type: string}, body: ?array{ids: array<string, array>}}}

◆ toInlineAttributeHtml()

Wikimedia\Parsoid\Core\HtmlPageBundle::toInlineAttributeHtml ( array $options = [],
?array & $fragments = null,
?SiteConfig $siteConfig = null )

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

Parameters
array$optionsXHtmlSerializer options
array<string,string>|null&$fragments Additional fragments from the page bundle which will also be serialized to HTML strings. This is an output parameter.
?SiteConfig$siteConfig
Returns
string an HTML string

◆ toJsonArray()

Wikimedia\Parsoid\Core\HtmlPageBundle::toJsonArray ( )

◆ toSingleDocumentHtml()

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

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

Parameters
array$optionsXHtmlSerializer options
Returns
string an HTML string

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