API: extraction/readability

better-web-search-mcp


better-web-search-mcp / extraction/readability

extraction/readability#

Interfaces#

ReadabilityResult#

Defined in: src/extraction/readability.ts:15

The result of a readability extraction.

Properties#

PropertyTypeDescriptionDefined in
bylinestringAuthor metadata, when present.src/extraction/readability.ts:27
contentMarkdownstringThe article content converted to Markdown.src/extraction/readability.ts:19
excerptstringA short excerpt / description of the article.src/extraction/readability.ts:23
lengthnumberLength of the article in characters.src/extraction/readability.ts:25
textContentstringPlain-text content with all HTML tags removed.src/extraction/readability.ts:21
titlestringThe article title.src/extraction/readability.ts:17

Functions#

extractWithReadability()#

extractWithReadability(html, url): ReadabilityResult | null

Defined in: src/extraction/readability.ts:47

Extract the main article from an HTML page.

  1. Cheerio pre-pass removes script/style/link/svg/data-image nodes so they never pollute the article or the Markdown output.
  2. The cleaned HTML is loaded into JSDOM (with the page URL for correct relative-link resolution).
  3. Mozilla Readability parses the document into an article.
  4. Turndown converts the article HTML to Markdown.

Returns null when the page has no readable article (Readability.parse returns null), so callers can escalate to a different extraction tier.

Parameters#

ParameterType
htmlstring
urlstring

Returns#

ReadabilityResult | null