-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a typescript definition with a generic serializer.
- Loading branch information
1 parent
2d35826
commit e1c7905
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Decides whether or not the document is reader-able without parsing the whole thing. | ||
* @return {boolean} Whether or not we suspect Readability.parse() will suceeed at returning an article object. | ||
*/ | ||
export function isProbablyReaderable( | ||
document: Document, | ||
options?: { | ||
/** The minimum node content length used to decide if the document is readerable. */ | ||
minContentLength?: number; | ||
/** The minumum cumulated 'score' used to determine if the document is readerable. */ | ||
minScore?: number; | ||
/** The function used to determine if a node is visible. */ | ||
visibilityChecker?: (node: Node) => boolean; | ||
} | ||
): boolean; | ||
|
||
export class Readability<T = string> { | ||
constructor( | ||
document: Document, | ||
options?: { | ||
debug?: boolean; | ||
maxElemsToParse?: number; | ||
nbTopCandidates?: number; | ||
charThreshold?: number; | ||
classesToPreserve?: string[]; | ||
keepClasses?: boolean; | ||
serializer?: (node: Node) => T; | ||
disableJSONLD?: boolean; | ||
} | ||
); | ||
|
||
parse(): null | { | ||
/** article title */ | ||
title: string; | ||
/** author metadata */ | ||
byline: string; | ||
/** content direction */ | ||
dir: string; | ||
/** HTML of processed article content */ | ||
content: T; | ||
/** text content of the article (all HTML removed) */ | ||
textContent: string; | ||
/** length of an article, in characters */ | ||
length: number; | ||
/** article description, or short excerpt from the content */ | ||
excerpt: string; | ||
siteName: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters