metascraper-readability 5.46.1 → 5.46.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,6 +27,18 @@ Default: [source code](https://github.com/microlinkhq/metascraper/blob/master/pa
27
27
 
28
28
  The function to be called to serialized html into a DOM document.
29
29
 
30
+ ##### readabilityOpts
31
+
32
+ Type: `object`
33
+
34
+ Any option provided here will passed to [Readability#options](https://github.com/mozilla/readability#new-readabilitydocument-options).
35
+
36
+ ```json
37
+ {
38
+ "responseType": "json"
39
+ }
40
+ ```
41
+
30
42
  ## License
31
43
 
32
44
  **metascraper-readability** © [Microlink](https://microlink.io), released under the [MIT](https://github.com/microlinkhq/metascraper/blob/master/LICENSE.md) License.<br>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "metascraper-readability",
3
3
  "description": "A Readability connector for metascraper",
4
4
  "homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-readability",
5
- "version": "5.46.1",
5
+ "version": "5.46.3",
6
6
  "types": "src/index.d.ts",
7
7
  "main": "src/index.js",
8
8
  "author": {
@@ -40,5 +40,5 @@
40
40
  "test": "NODE_PATH=.. TZ=UTC ava --timeout 15s"
41
41
  },
42
42
  "license": "MIT",
43
- "gitHead": "67b5fc0d544f02e540e6546745c9fdced13c4973"
43
+ "gitHead": "b7e00b77ec5d4a00017e50628d947829cf11461a"
44
44
  }
package/src/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
- declare function rules(): import('metascraper').Rules;
1
+ type Options = {
2
+ getDocument: ({url: string, html: string }) => Document,
3
+ readabilityOpts: import('readability').ReadabilityOptions,
4
+ }
5
+
6
+ declare function rules(options?: Options): import('metascraper').Rules;
2
7
  export = rules;
package/src/index.js CHANGED
@@ -19,10 +19,13 @@ const defaultGetDocument = ({ url, html }) => {
19
19
  return document
20
20
  }
21
21
 
22
- module.exports = ({ getDocument = defaultGetDocument } = {}) => {
22
+ module.exports = ({
23
+ getDocument = defaultGetDocument,
24
+ readabilityOpts
25
+ } = {}) => {
23
26
  const readability = memoizeOne((url, html, getDocument) => {
24
27
  const document = getDocument({ url, html })
25
- const reader = new Readability(document)
28
+ const reader = new Readability(document, readabilityOpts)
26
29
  return parseReader(reader)
27
30
  }, memoizeOne.EqualityFirstArgument)
28
31