2.0.0 • Published 8 years ago

readability-from-string v2.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

readability-from-string

Build status NPM version XO code style

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)

NameTypeDescription
htmlStringThe HTML to run Readability on
optionsObjectOptions

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