/** * Stage 3: HTML block segmentation. * * The DOM is walked with node-html-parser, which exposes a source `range` on every node. That is * the reason it is used here rather than a faster tag stripper: a block that cannot point back at * the exact source offsets it came from cannot be traced, and traceability is a requirement. * * Segmentation emits one block per run of inline content between block level elements. A container * such as a Gmail quote wrapper does not become a block itself; instead every block inside it * records its ancestry. That is deliberate, because interleaved replies put new content inside and * between quote containers, and a container-level decision cannot express that. * * Blocks tile the source: each block's range is extended backwards to the end of the previous * block, and the last block runs to the end of the document, so concatenating block texts * reproduces the HTML exactly. */ import { type Block } from './types'; export interface HtmlSegmentation { /** The source HTML, unchanged. All block offsets refer to this string. */ source: string; blocks: Block[]; /** True when parsing failed and a degraded single block was produced. */ degraded: boolean; } /** * The elements node-html-parser would leave open at the end of the document, and the number of * text runs it would create, from one linear pass over the source. * * Tags are delimited the way the parser's markup pattern delimits them: a name starts with an * ASCII letter right after `<` or ``, a quoted attribute * value may contain `>` when its closing quote exists, a comment or CDATA section is one unit, and * the content of a raw text element is skipped to its end tag, or to the end of the input when * there is none, which is where the parser stops too. A `<` that opens no tag is text. Searches * for a delimiter that is not there are remembered, so an input full of unterminated quotes or * comments does not rescan its suffix once per opener. */ export declare function scanMarkup(html: string): { unclosedTags: number; textRuns: number; }; /** True when markup is shaped badly enough that parsing it is not worth the time. */ export declare function isPathologicalHtml(html: string): boolean; export declare function segmentHtmlBlocks(html: string, mimePart: string): HtmlSegmentation; //# sourceMappingURL=html-blocks.d.ts.map