Skip to content

Commit

Permalink
Documented new dom parsing options
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Feb 6, 2015
1 parent dadacf8 commit 8d51ad4
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,35 @@ $html5->save($dom, 'out.html');
The `$dom` created by the parser is a full `DOMDocument` object. And the
`save()` and `saveHTML()` methods will take any DOMDocument.

### Options

It is possible to pass in an array of configuration options when loading
an HTML5 document.

```php
// An associative array of options
$options = array(
'option_name' => 'option_value',
);

// Provide the options to the constructor
$html5 = new HTML5($options);

$dom = $html5->loadHTML($html);
```

The following options are supported:

* `encode_entities` (boolean): Indicates that the serializer should aggressively
encode characters as entities. Without this, it only encodes the bare
minimum.
* `disable_html_ns` (boolean): Prevents the parser from automatically
assigning the HTML5 namespace to the DOM document. This is for
non-namespace aware DOM tools.
* `target_doc` (\DOMDocument): A DOM document that will be used as the
destination for the parsed nodes.
* `implicit_namespaces` (array): An assoc array of namespaces that should be
used by the parser. Name is tag prefix, value is NS URI.

## The Low-Level API

Expand Down Expand Up @@ -200,15 +229,6 @@ $dom->documentElement->namespaceURI; // http://www.example.com

```

## Parser and Serializer Options

* `disableHtmlNsInDom` (boolean):
* If `true`, HTML DOM nodes are not namespaced.
* If not set or `false`, HTML nodes are namespaced ( using `http://www.w3.org/1999/xhtml` namespace) as by official specs.
* `targetDocument` (instanceof `DOMNode`):
* If set, the resulting DOM nodes from the HTML parsing will be appended as its childrens.
* If not set, to store the resulting DOM nodes from the HTML parsing a new `DOMDocument` or `DOMDocumentFragment` will be created.

## Thanks to...

The dedicated (and patient) contributors of patches small and large,
Expand Down

0 comments on commit 8d51ad4

Please sign in to comment.