v9.0.0 - Deno/JSR first
- Rewrite in TypeScript, with Deno/JSR as primary target
- Allow consumer to custom fetcher (replace old fetchOptions)
- Simplify html sanitizing with built-in function (remove sanitize-html dependency and related config methods)
- Fix JSON-LD logic (#425)
Breaking changes
Use custom fetcher instead of fetchOptions
Before v9.0.0:
import { extract } from '@extractus/article-extractor'
const url = 'https://example.com/some-article'
const article = await extract(url, {}, {
headers: {
'user-agent': 'Opera/9.60 (Windows NT 6.0; U; en) Presto/2.1.1'
}
})Since v9.0.0:
const myFetcher = (url: string) =>
fetch(url, {
headers: {
"user-agent": "Opera/9.60 (Windows NT 6.0; U; en) Presto/2.1.1",
},
});
const article = await extract("https://example.com/some-article", {}, myFetcher);Configure content sanitizing via parserOptions
Before v9.0.0:
import { setSanitizeHtmlOptions } from '@extractus/article-extractor'
setSanitizeHtmlOptions({
allowedAttributes: {
a: ["href", "target", "title"],
img: ["src", "srcset", "alt", "title"],
code: ["class"],
div: ["class"],
},
})Since v9.0.0:
import { extract } from "jsr:@extractus/article-extractor";
const article = await extract(url, {
allowedAttributes: {
a: ["href", "target", "title"],
img: ["src", "srcset", "alt", "title"],
code: ["class"],
div: ["class"],
},
});Check README for more detail.