mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* feat(jsdom): Update to v16.1 * test(mozilla‑readability): Remove test dependency on JSDOM * fix(jsdom): Fix lint errors * feat(jsdom): Update dependency parse5 to v5
35 lines
985 B
TypeScript
35 lines
985 B
TypeScript
import Readability = require('mozilla-readability');
|
|
|
|
declare class JSDOM {
|
|
constructor(html?: string);
|
|
|
|
readonly window: Window;
|
|
}
|
|
|
|
// Compiling requires `--noImplicitUseStrict`
|
|
// because issue https://github.com/mozilla/readability/issues/346
|
|
// requires global variable `Node` when using nodejs.
|
|
|
|
function test_basic_usage() {
|
|
const dom = new JSDOM(`<p>Hello</p><p><strong>Hi!</strong>`);
|
|
|
|
const reader = new Readability(dom.window.document);
|
|
const article = reader.parse();
|
|
}
|
|
|
|
function test_readability_with_options() {
|
|
const dom = new JSDOM(`<p>Hello</p><p><strong>Hi!</strong>`);
|
|
|
|
const options: Readability.Options = {
|
|
debug: true,
|
|
maxElemsToParse: 100,
|
|
};
|
|
const article = new Readability(dom.window.document, options).parse();
|
|
}
|
|
|
|
function test_is_probably_readerable() {
|
|
const dom = new JSDOM(`<p>Hello</p><p><strong>Hi!</strong>`);
|
|
|
|
const isReadable = new Readability(dom.window.document).isProbablyReaderable();
|
|
}
|