Mention you need a DOM document object

Per #376 it doesn't seem to be clear that you need a DOM to use Readability. This is an attempt to include this information in the README.
pull/377/head
Gijs 7 years ago committed by GitHub
parent 924017c686
commit ab09b706ed

@ -16,7 +16,7 @@ Please make sure to run [eslint](http://eslint.org/) against any proposed change
## Usage
To parse a document, you must create a new `Readability` object from a URI object and a document, and then call `parse()`. Here's an example:
To parse a document, you must create a new `Readability` object from a URI object and a document object, and then call `parse()`. Here's an example:
```javascript
var loc = document.location;
@ -40,6 +40,8 @@ This `article` object will contain the following properties:
* `byline`: author metadata
* `dir`: content direction
If you're using Readability on the web, you will likely be able to use a `document` reference from elsewhere (e.g. fetched via XMLHttpRequest, in a same-origin `<iframe>` you have access to, etc.). Otherwise, you would need to construct such an object using a DOM parser such as [jsdom](https://github.com/tmpvar/jsdom). While this repository contains a parser of its own (`JSDOMParser`), that is restricted to reading XML-compatible markup and therefore we do not recommend it for general use.
### Optional
Readability's `parse()` works by modifying the DOM. This removes some elements in the web page. You could avoid this by passing the clone of the `document` object while creating a `Readability` object.

Loading…
Cancel
Save