Skip to main content

parse_stream

Function parse_stream 

Source
pub fn parse_stream<'a>(
    chunks: impl Iterator<Item = &'a [u8]>,
) -> Result<Document, HtmlError>
Expand description

Parse an HTML document from an iterator of byte chunks.

Detects encoding from the first 1 KB and builds the tree incrementally.

ยงExample

use fhp_tree::streaming::parse_stream;

let html = b"<div><p>Hello</p></div>";
let doc = parse_stream(html.chunks(64)).unwrap();
assert_eq!(doc.root().text_content(), "Hello");