A formatter which follows the HTML 5 fragment serialization algorithm.
More...
|
| __construct ( $options=[]) |
| Constructor.
|
|
| startDocument ( $fragmentNamespace, $fragmentName) |
| Get a string which starts the document.
|
|
| characters (SerializerNode $parent, $text, $start, $length) |
| Encode the given character substring.
|
|
| element (SerializerNode $parent, SerializerNode $node, $contents) |
| Encode the given element.
|
|
| comment (SerializerNode $parent, $text) |
| Encode a comment.
|
|
| doctype ( $name, $public, $system) |
| Encode a doctype.
|
|
string | formatDOMElement ( $node, $contents) |
|
string | formatDOMNode (DOMNode $node) |
| Recursively format a DOMNode.
|
|
| formatDOMElement (DOMElement $element, $contents) |
| Non-recursively format a DOMElement.
|
|
|
array< string, bool > | $voidElements |
| The elements for which a closing tag is omitted.
|
|
array< string, bool > | $prefixLfElements |
| The elements which need a leading newline in their contents to be duplicated, since the parser strips a leading newline.
|
|
array< string, bool > | $rawTextElements |
| The elements which have unescaped contents.
|
|
array< string, string > | $attributeEscapes |
| The escape table for attribute values.
|
|
array< string, string > | $textEscapes |
| The escape table for text nodes.
|
|
array< string, bool > | $unqualifiedNamespaces |
| Attribute namespaces which have unqualified local names.
|
|
| $useSourceDoctype |
|
| $reverseCoercion |
|
A formatter which follows the HTML 5 fragment serialization algorithm.
◆ __construct()
Wikimedia\RemexHtml\Serializer\HtmlFormatter::__construct |
( |
| $options = [] | ) |
|
Constructor.
- Parameters
-
array | $options | An associative array of options:
- scriptingFlag : Set this to false to disable scripting. True by default.
- useSourceDoctype : Emit the doctype used in the source. If this is false or absent, an HTML doctype will be used.
- reverseCoercion : When formatting a DOM node, reverse the encoding of invalid names. False by default.
|
Reimplemented in Wikimedia\RemexHtml\Serializer\DepurateFormatter.
◆ characters()
Wikimedia\RemexHtml\Serializer\HtmlFormatter::characters |
( |
SerializerNode | $parent, |
|
|
| $text, |
|
|
| $start, |
|
|
| $length ) |
Encode the given character substring.
- Parameters
-
SerializerNode | $parent | The parent of the text node (at creation time) |
string | $text | |
int | $start | The offset within $text |
int | $length | The number of bytes within $text |
- Returns
- string
Implements Wikimedia\RemexHtml\Serializer\Formatter.
◆ comment()
Wikimedia\RemexHtml\Serializer\HtmlFormatter::comment |
( |
SerializerNode | $parent, |
|
|
| $text ) |
◆ doctype()
Wikimedia\RemexHtml\Serializer\HtmlFormatter::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 | $name | The doctype name, usually "html" |
string | $public | The PUBLIC identifier |
string | $system | The SYSTEM identifier |
- Returns
- string
Implements Wikimedia\RemexHtml\Serializer\Formatter.
◆ element()
◆ formatDOMElement()
string Wikimedia\RemexHtml\Serializer\HtmlFormatter::formatDOMElement |
( |
| $node, |
|
|
| $contents ) |
- Parameters
-
\DOMElement | $node | |
string | $contents | |
- Returns
- string
◆ startDocument()
Wikimedia\RemexHtml\Serializer\HtmlFormatter::startDocument |
( |
| $fragmentNamespace, |
|
|
| $fragmentName ) |
◆ $attributeEscapes
array<string,string> Wikimedia\RemexHtml\Serializer\HtmlFormatter::$attributeEscapes |
|
protected |
Initial value:= array(
'&' => '&',
"\xc2\xa0" => ' ',
'"' => '"',
)
The escape table for attribute values.
◆ $prefixLfElements
array<string,bool> Wikimedia\RemexHtml\Serializer\HtmlFormatter::$prefixLfElements |
|
protected |
Initial value:= array(
'pre' => true,
'textarea' => true,
'listing' => true
)
The elements which need a leading newline in their contents to be duplicated, since the parser strips a leading newline.
◆ $rawTextElements
array<string,bool> Wikimedia\RemexHtml\Serializer\HtmlFormatter::$rawTextElements |
|
protected |
Initial value:= array(
'style' => true,
'script' => true,
'xmp' => true,
'iframe' => true,
'noembed' => true,
'noframes' => true,
'plaintext' => true,
)
The elements which have unescaped contents.
◆ $textEscapes
array<string,string> Wikimedia\RemexHtml\Serializer\HtmlFormatter::$textEscapes |
|
protected |
Initial value:= array(
'&' => '&',
"\xc2\xa0" => ' ',
'<' => '<',
'>' => '>',
)
The escape table for text nodes.
◆ $unqualifiedNamespaces
array<string,bool> Wikimedia\RemexHtml\Serializer\HtmlFormatter::$unqualifiedNamespaces |
|
protected |
Initial value:= array(
HTMLData::NS_HTML => true,
HTMLData::NS_MATHML => true,
HTMLData::NS_SVG => true,
)
Attribute namespaces which have unqualified local names.
◆ $voidElements
array<string,bool> Wikimedia\RemexHtml\Serializer\HtmlFormatter::$voidElements |
|
protected |
Initial value:= array(
'area' => true,
'base' => true,
'basefont' => true,
'bgsound' => true,
'br' => true,
'col' => true,
'embed' => true,
'frame' => true,
'hr' => true,
'img' => true,
'input' => true,
'keygen' => true,
'link' => true,
'menuitem' => true,
'meta' => true,
'param' => true,
'source' => true,
'track' => true,
'wbr' => true,
)
The elements for which a closing tag is omitted.
The documentation for this class was generated from the following file:
- src/Serializer/HtmlFormatter.php