2.0.0 • Published 8 years ago
readability-from-string v2.0.0
readability-from-string
Run mozilla/readability on an HTML string
This is just a convenience wrapper around mozilla/readability.
Installation
Install readability-from-string
using npm:
npm install --save readability-from-string
Usage
Module usage
const readabilityFromString = require('readability-from-string');
const html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Your html</title>
</head>
<body>
<article>
...
</article>
</body>
</html>
`;
const result = readabilityFromString(html, {href: 'http://original.location.com/of/html.source'});
API
readabilityFromString(html, options)
Name | Type | Description |
---|---|---|
html | String | The HTML to run Readability on |
options | Object | Options |
Returns: Object
on success or NULL
when no content was found.
options.href
Type: String
Required: true
Should contain the full URL for the HTML source. This is used to fix relative paths within the HTML.
License
MIT © Joakim Carlstein