Browse Source

Updates to documentation

domparser
Dustin Wilson 2 years ago
parent
commit
f33cc4344b
  1. 14
      README.md

14
README.md

@ -61,14 +61,14 @@ Unlike the `parse()` method, the `parseFragment()` method returns a `DOMDocument
```php
public static MensBeam\HTML\Parser::serialize(
DOMNode $node,
?MensBeam\HTML\Parser\Config $config = null
array $config = []
): string
```
```php
public static MensBeam\HTML\Parser::serializeInner(
DOMNode $node,
?MensBeam\HTML\Parser\Config $config = null
array $config = []
): string
```
@ -88,6 +88,14 @@ Similarly, the `MensBeam\HTML\Parser::serializeInner` method can be used to conv
- `DOMElement`
- `DOMDocumentFragment`
The serialization methods use an associative array for configuration, and the possible keys and value types are:
- `booleanAttributeValues` (`bool|null`): Whether to include the values of boolean attributes on HTML elements during serialization. Per the standard this is `true` by default
- `foreignVoidEndTags` (`bool|null`): Whether to print the end tags of foreign void elements rather than self-closing their start tags. Per the standard this is `true` by default
- `indentStep` (`int|null`): The number of spaces or tabs (depending on setting of indentStep) to indent at each step. This is `1` by default and has no effect unless `reformatWhitespace` is `true`
- `indentWithSpaces` (`bool|null`): Whether to use spaces or tabs to indent. This is `true` by default and has no effect unless `reformatWhitespace` is `true`
- `reformatWhitespace` (`bool|null`): Whether to reformat whitespace (pretty-print) or not. This is `false` by default
## Examples
- Parsing a document with unknown encoding:
@ -178,8 +186,6 @@ The `MensBeam\HTML\Parser\Config` class is used as a container for configuration
- `errorCollection`: A boolean value indicating whether parse errors should be collected into the `Output` object's `errors` array. This should usually be left at the default `false` for performance reasons. The content of the `errors` array is currently considered an implemenmtation detail subject to change without notice
- `htmlNamespace`: A boolean value indicating whether to create HTML elements within the HTML namespace i.e. `http://www.w3.org/1999/xhtml` rather than the `null` namespace. Though using the HTML namespace is the correct behaviour, the `null` namespace is used by default for performance and compatibility reasons
- `processingInstructions`: A boolean value indicating whether to preserve processing instructions in the parsed document. By default processing instructions are parsed as comments, per the specification. Note that if set to `true` the parser will insert _HTML processing sinstructions_ which are terminated by the first `>` character, not XML processing instructions terminated by `?>`
- `serializeForeignVoidEndTags`: A boolean value indication whether the print the end tags of empty foreign elements rather than self-closing their start tags. By default this is `true`
- `serializeBooleanAttributeValues`: A boolean value indication whether the print the values of boolean attributes on HTML elements rather only the attribute names. By default this is `true`
## Limitations

Loading…
Cancel
Save