Parsoid
A bidirectional parser between wikitext and HTML5
Parsoid\Parsoid Class Reference

Public Member Functions

 __construct (SiteConfig $siteConfig, DataAccess $dataAccess)
 
 wikitext2html (PageConfig $pageConfig, array $options=[])
 Parse the wikitext supplied in a PageConfig to HTML. More...
 
 wikitext2lint (PageConfig $pageConfig, array $options=[])
 Lint the wikitext supplied in a PageConfig. More...
 
 html2wikitext (PageConfig $pageConfig, string $html, array $options=[], ?SelserData $selserData=null)
 Serialize HTML to wikitext. More...
 
 html2html (PageConfig $pageConfig, string $update, string $html, array $options=[])
 Update the supplied HTML based on the $update type. More...
 

Constructor & Destructor Documentation

◆ __construct()

Parsoid\Parsoid::__construct ( SiteConfig  $siteConfig,
DataAccess  $dataAccess 
)
Parameters
SiteConfig$siteConfig
DataAccess$dataAccess

Member Function Documentation

◆ html2html()

Parsoid\Parsoid::html2html ( PageConfig  $pageConfig,
string  $update,
string  $html,
array  $options = [] 
)

Update the supplied HTML based on the $update type.

'redlinks': Refreshes the classes of known, missing, etc. links. 'variant': Hydrates the HTML based on the supplied variant.

Note that these are DOM transforms, and not roundtrips through wikitext.

Parameters
PageConfig$pageConfig
string$update'redlinks'|'variant'
string$html
array | null$options
Returns
string

◆ html2wikitext()

Parsoid\Parsoid::html2wikitext ( PageConfig  $pageConfig,
string  $html,
array  $options = [],
?SelserData  $selserData = null 
)

Serialize HTML to wikitext.

Parameters
PageConfig$pageConfig
string$htmlData attributes are expected to have been applied already. Loading them will happen once the environment is created.
array$options[ 'scrubWikitext' => (bool) Indicates emit "clean" wikitext. 'inputContentVersion' => (string) The content version of the input. Necessary if it differs from the current default in order to account for any serialization differences. 'offsetType' => (string) ucs2, char, byte are valid values what kind of source offsets are present in the HTML? 'traceFlags' => (array) associative array with tracing options 'dumpFlags' => (array) associative array with dump options 'debugFlags' => (array) associative array with debug options ]
SelserData | null$selserData
Returns
string

◆ wikitext2html()

Parsoid\Parsoid::wikitext2html ( PageConfig  $pageConfig,
array  $options = [] 
)

Parse the wikitext supplied in a PageConfig to HTML.

Parameters
PageConfig$pageConfig
array$options[ 'wrapSections' => (bool) Whether <section> wrappers should be added. 'pageBundle' => (bool) Sets ids on nodes and stores data-* attributes in a JSON blob. 'body_only' => (bool|null) Only return the <body> children (T181657) 'outputVersion' => (string|null) Version of HTML to output. null returns the default version. 'inlineDataAttribs' => (bool) Setting to true avoids extracting data attributes. 'discardDataParsoid' => (bool) Drop all data-parsoid annotations. 'offsetType' => (string) ucs2, char, byte are valid values what kind of source offsets should be emitted? 'traceFlags' => (array) associative array with tracing options 'dumpFlags' => (array) associative array with dump options 'debugFlags' => (array) associative array with debug options ]
Returns
PageBundle|string

◆ wikitext2lint()

Parsoid\Parsoid::wikitext2lint ( PageConfig  $pageConfig,
array  $options = [] 
)

Lint the wikitext supplied in a PageConfig.

Parameters
PageConfig$pageConfig
array$optionsSee wikitext2html.
Returns
array

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