Parsing the DOM and Finding the Article
The page is parsed with DOMParser into an inert document: scripts do not run, and the result is a tree that can be walked safely. Before conversion, drop script, style, noscript, iframe, form and svg nodes. Readability-style scoring then ranks containers by paragraph length, comma frequency and link density, which separates an article body from navigation, cookie banners and comment threads.
Picking the wrong container is the most common failure. A documentation page may have its content split across sibling sections, so a strict top-one heuristic loses half the text; a news site may wrap the body in a div that also contains related links. Expose the candidate list, and let the user override the selection before conversion rather than guessing silently.