Function: readHtml()
readHtml(
document,options?):HtmlRead
Defined in: packages/agentos/src/cognition/library/readers/html.ts:1520
Reads a parsed HTML page into its title and its body as Markdown. The body leaves out the head, scripts, styles,
templates, noscript, nav, search, the page's own header, footer and aside, frames, a form that holds no
page, the controls of a form that hold words of their own (button, select, textarea) and a datalist with its
choices, embedded media, drawings in SVG and formulas in MathML, a dialog that is not open, and any element marked
hidden, aria-hidden="true" or styled display: none. A header, footer or aside is the page's own when no
article or section holds it but a section that holds the page's main content, a main element or an element whose
role is main, and so wraps the page; inside an article or any other section, it is that part's and is read with it,
and an article or section handed over holds its own the same way. A header inside the page's main content that
holds an h1 introduces that content: its headings, hgroups and paragraphs are read, and the rest of it, a menu or
a list of links beside them, is the page's own; one that holds no h1 is the page's own whole. A form is read as
the blocks it holds when it holds a page: a heading, an article, aside, nav or section, the page's main
content, a header, a footer or a table's header cell (th), as a table of data holds; when it is the page's main
content itself; or when it is the one element the body holds, as a page whose whole body sits in one form does. The
header cells of a table with a row that puts one beside a td of a control and no words, as a contact form laid out
in a table puts its labels, mark no page. A heading whose words all sit in its one button,
as an accordion's header's do, is read for that button's words. A form's control, an image and the rest of HTML's
embedded content are each a space between the words on either side of them, outside code. Comments are not read. An
element handed over is read as a document is, whatever its own name, but an svg or math element handed over
takes no title from a <title> in it, which is the drawing's or the formula's.
Parameters
document
A parsed document, or an element, as a page's DOMParser gives it; nothing is fetched.
options?
The bounds on the Markdown and on each table.
Returns
Throws
RangeError for a bound below 0, NaN or no number at all (null, a numeric text, true).