RemexHtml
Fast HTML 5 parser
Loading...
Searching...
No Matches
Wikimedia\RemexHtml\Serializer\Formatter Interface Reference

The interface for classes that help Serializer to convert nodes to strings. More...

+ Inheritance diagram for Wikimedia\RemexHtml\Serializer\Formatter:

Public Member Functions

string startDocument ( $fragmentNamespace, $fragmentName)
 Get a string which starts the document.
 
string characters (SerializerNode $parent, $text, $start, $length)
 Encode the given character substring.
 
string element (SerializerNode $parent, SerializerNode $node, $contents)
 Encode the given element.
 
string comment (SerializerNode $parent, $text)
 Encode a comment.
 
string doctype ( $name, $public, $system)
 Encode a doctype.
 

Detailed Description

The interface for classes that help Serializer to convert nodes to strings.

Serializer assumes that the return values of these functions can be concatenated to make a document.

It is not safe to assume that the methods will be called in any particular order, or that the return values will actually be retained in the final Serializer result.

Member Function Documentation

◆ characters()

string Wikimedia\RemexHtml\Serializer\Formatter::characters ( SerializerNode $parent,
$text,
$start,
$length )

Encode the given character substring.

Parameters
SerializerNode$parentThe parent of the text node (at creation time)
string$text
int$startThe offset within $text
int$lengthThe number of bytes within $text
Returns
string

Implemented in Wikimedia\RemexHtml\Serializer\FastFormatter, Wikimedia\RemexHtml\Serializer\HtmlFormatter, and Wikimedia\RemexHtml\Serializer\TestFormatter.

◆ comment()

string Wikimedia\RemexHtml\Serializer\Formatter::comment ( SerializerNode $parent,
$text )

Encode a comment.

Parameters
SerializerNode$parentThe parent of the node (at creation time)
string$textThe inner text of the comment
Returns
string

Implemented in Wikimedia\RemexHtml\Serializer\FastFormatter, Wikimedia\RemexHtml\Serializer\HtmlFormatter, and Wikimedia\RemexHtml\Serializer\TestFormatter.

◆ doctype()

string Wikimedia\RemexHtml\Serializer\Formatter::doctype ( $name,
$public,
$system )

Encode a doctype.

This event occurs when the source document has a doctype, it can return an empty string if the formatter wants to use its own doctype.

Parameters
string$nameThe doctype name, usually "html"
string$publicThe PUBLIC identifier
string$systemThe SYSTEM identifier
Returns
string

Implemented in Wikimedia\RemexHtml\Serializer\FastFormatter, Wikimedia\RemexHtml\Serializer\HtmlFormatter, and Wikimedia\RemexHtml\Serializer\TestFormatter.

◆ element()

string Wikimedia\RemexHtml\Serializer\Formatter::element ( SerializerNode $parent,
SerializerNode $node,
$contents )

Encode the given element.

Parameters
SerializerNode$parentThe parent of the node (when it is closed)
SerializerNode$nodeThe element to encode
string | null$contentsThe previously-encoded contents, or null for a void element. Void elements can be serialized as self-closing tags.
Returns
string

Implemented in Wikimedia\RemexHtml\Serializer\DepurateFormatter, Wikimedia\RemexHtml\Serializer\FastFormatter, Wikimedia\RemexHtml\Serializer\HtmlFormatter, and Wikimedia\RemexHtml\Serializer\TestFormatter.

◆ startDocument()

string Wikimedia\RemexHtml\Serializer\Formatter::startDocument ( $fragmentNamespace,
$fragmentName )

Get a string which starts the document.

Parameters
string | null$fragmentNamespace
string | null$fragmentName
Returns
string

Implemented in Wikimedia\RemexHtml\Serializer\FastFormatter, Wikimedia\RemexHtml\Serializer\HtmlFormatter, and Wikimedia\RemexHtml\Serializer\TestFormatter.


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