import { Readability } from "@mozilla/readability";
import { parseHTML } from "linkedom";
import { htmlToMarkdown } from "./markdown.js";
const MIN_CONTENT_THRESHOLD = 100;
function readabilityExtract(html, _url) {
  try {
    const { document } = parseHTML(html);
    const reader = new Readability(document);
    const article = reader.parse();
    if (!article || !article.content) return null;
    const markdown = htmlToMarkdown(article.content);
    if (markdown.length < MIN_CONTENT_THRESHOLD) return null;
    return {
      title: article.title ?? "",
      markdown,
      metadata: {
        author: article.byline || void 0,
        language: article.lang || void 0
      },
      links: [],
      images: [],
      extractor: "readability"
    };
  } catch {
    return null;
  }
}
export {
  readabilityExtract
};
//# sourceMappingURL=readability.js.map